Import ncpfs 2.2.1

This commit is contained in:
ncpfs archive import
2026-04-28 20:39:59 +02:00
parent 0979ae6a41
commit 82706139bf
547 changed files with 176953 additions and 12604 deletions

View File

@@ -0,0 +1,127 @@
#ifndef _PRIVATE_ALPHA_ATOMIC_H
#define _PRIVATE_ALPHA_ATOMIC_H
#define mb() \
__asm__ __volatile__("mb": : :"memory")
#define rmb() \
__asm__ __volatile__("mb": : :"memory")
#define wmb() \
__asm__ __volatile__("wmb": : :"memory")
#define smp_mb() mb()
#define smp_rmb() rmb()
#define smp_wmb() wmb()
/*
* Atomic operations that C can't guarantee us. Useful for
* resource counting etc...
*
* But use these as seldom as possible since they are much slower
* than regular operations.
*/
/*
* Counter is volatile to make sure gcc doesn't try to be clever
* and move things around on us. We need to use _exactly_ the address
* the user gave us, not some alias that contains the same information.
*/
typedef struct { volatile int counter; } ncpt_atomic_t;
#define NCPT_ATOMIC_INIT(i) ( (ncpt_atomic_t) { (i) } )
#define ncpt_atomic_read(v) ((v)->counter)
#define ncpt_atomic_set(v,i) ((v)->counter = (i))
/*
* To get proper branch prediction for the main line, we must branch
* forward to code at the end of this object's .text section, then
* branch back to restart the operation.
*/
static __inline__ void ncpt_atomic_add(int i, ncpt_atomic_t * v)
{
unsigned long temp;
__asm__ __volatile__(
"1: ldl_l %0,%1\n"
" addl %0,%2,%0\n"
" stl_c %0,%1\n"
" beq %0,2f\n"
".subsection 2\n"
"2: br 1b\n"
".previous"
:"=&r" (temp), "=m" (v->counter)
:"Ir" (i), "m" (v->counter));
}
static __inline__ void ncpt_atomic_sub(int i, ncpt_atomic_t * v)
{
unsigned long temp;
__asm__ __volatile__(
"1: ldl_l %0,%1\n"
" subl %0,%2,%0\n"
" stl_c %0,%1\n"
" beq %0,2f\n"
".subsection 2\n"
"2: br 1b\n"
".previous"
:"=&r" (temp), "=m" (v->counter)
:"Ir" (i), "m" (v->counter));
}
/*
* Same as above, but return the result value
*/
static __inline__ long ncpt_atomic_add_return(int i, ncpt_atomic_t * v)
{
long temp, result;
__asm__ __volatile__(
"1: ldl_l %0,%1\n"
" addl %0,%3,%2\n"
" addl %0,%3,%0\n"
" stl_c %0,%1\n"
" beq %0,2f\n"
" mb\n"
".subsection 2\n"
"2: br 1b\n"
".previous"
:"=&r" (temp), "=m" (v->counter), "=&r" (result)
:"Ir" (i), "m" (v->counter) : "memory");
return result;
}
static __inline__ long ncpt_atomic_sub_return(int i, ncpt_atomic_t * v)
{
long temp, result;
__asm__ __volatile__(
"1: ldl_l %0,%1\n"
" subl %0,%3,%2\n"
" subl %0,%3,%0\n"
" stl_c %0,%1\n"
" beq %0,2f\n"
" mb\n"
".subsection 2\n"
"2: br 1b\n"
".previous"
:"=&r" (temp), "=m" (v->counter), "=&r" (result)
:"Ir" (i), "m" (v->counter) : "memory");
return result;
}
#define ncpt_atomic_dec_return(v) ncpt_atomic_sub_return(1,(v))
#define ncpt_atomic_inc_return(v) ncpt_atomic_add_return(1,(v))
#define ncpt_atomic_sub_and_test(i,v) (ncpt_atomic_sub_return((i), (v)) == 0)
#define ncpt_atomic_dec_and_test(v) (ncpt_atomic_sub_return(1, (v)) == 0)
#define ncpt_atomic_inc(v) ncpt_atomic_add(1,(v))
#define ncpt_atomic_dec(v) ncpt_atomic_sub(1,(v))
#define smp_mb__before_ncpt_atomic_dec() smp_mb()
#define smp_mb__after_ncpt_atomic_dec() smp_mb()
#define smp_mb__before_ncpt_atomic_inc() smp_mb()
#define smp_mb__after_ncpt_atomic_inc() smp_mb()
#endif /* _ALPHA_ATOMIC_H */

View File

@@ -0,0 +1,54 @@
#ifndef __PRIVATE_LIBNCP_GENERIC_ATOMIC_H__
#define __PRIVATE_LIBNCP_GENERIC_ATOMIC_H__
#include "config.h"
#include "private/libncp-lock.h"
typedef struct {
int counter;
ncpt_mutex_t mutex;
} ncpt_atomic_t;
#define NCPT_ATOMIC_INIT(i) { (i), NCPT_MUTEX_INITIALIZER }
static inline int ncpt_atomic_read(ncpt_atomic_t* v) {
int tmp;
ncpt_mutex_lock(&v->mutex);
tmp = v->counter;
ncpt_mutex_unlock(&v->mutex);
return tmp;
}
static inline int ncpt_atomic_set(ncpt_atomic_t* v, int i) {
v->counter = i;
ncpt_mutex_init(&v->mutex);
return i;
}
static inline void ncpt_atomic_add(int i, ncpt_atomic_t* v) {
ncpt_mutex_lock(&v->mutex);
v->counter += i;
ncpt_mutex_unlock(&v->mutex);
}
static inline void ncpt_atomic_sub(int i, ncpt_atomic_t* v) {
ncpt_mutex_lock(&v->mutex);
v->counter -= i;
ncpt_mutex_unlock(&v->mutex);
}
#define ncpt_atomic_inc(v) ncpt_atomic_add(1,v)
#define ncpt_atomic_dec(v) ncpt_atomic_sub(1,v)
static inline int ncpt_atomic_dec_and_test(ncpt_atomic_t* v) {
int tmp;
ncpt_mutex_lock(&v->mutex);
tmp = !(--v->counter);
ncpt_mutex_unlock(&v->mutex);
return tmp;
}
#endif /* __PRIVATE_LIBNCP_GENERIC_ATOMIC_H__ */

View File

@@ -0,0 +1,202 @@
#ifndef __PRIVATE_ASM_I386_ATOMIC__
#define __PRIVATE_ASM_I386_ATOMIC__
/* Optimization barrier */
/* The "volatile" is due to gcc bugs */
#define barrier() __asm__ __volatile__("": : :"memory")
/*
* Atomic operations that C can't guarantee us. Useful for
* resource counting etc..
*/
#define LOCK "lock ; "
/*
* Make sure gcc doesn't try to be clever and move things around
* on us. We need to use _exactly_ the address the user gave us,
* not some alias that contains the same information.
*/
typedef struct { volatile int counter; } ncpt_atomic_t;
#define NCPT_ATOMIC_INIT(i) { (i) }
/**
* ncpt_atomic_read - read atomic variable
* @v: pointer of type ncpt_atomic_t
*
* Atomically reads the value of @v. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
#define ncpt_atomic_read(v) ((v)->counter)
/**
* ncpt_atomic_set - set atomic variable
* @v: pointer of type ncpt_atomic_t
* @i: required value
*
* Atomically sets the value of @v to @i. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
#define ncpt_atomic_set(v,i) (((v)->counter) = (i))
/**
* ncpt_atomic_add - add integer to atomic variable
* @i: integer value to add
* @v: pointer of type ncpt_atomic_t
*
* Atomically adds @i to @v. Note that the guaranteed useful range
* of an ncpt_atomic_t is only 24 bits.
*/
static __inline__ void ncpt_atomic_add(int i, ncpt_atomic_t *v)
{
__asm__ __volatile__(
LOCK "addl %1,%0"
:"=m" (v->counter)
:"ir" (i), "m" (v->counter));
}
/**
* ncpt_atomic_sub - subtract the atomic variable
* @i: integer value to subtract
* @v: pointer of type ncpt_atomic_t
*
* Atomically subtracts @i from @v. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
static __inline__ void ncpt_atomic_sub(int i, ncpt_atomic_t *v)
{
__asm__ __volatile__(
LOCK "subl %1,%0"
:"=m" (v->counter)
:"ir" (i), "m" (v->counter));
}
/**
* ncpt_atomic_sub_and_test - subtract value from variable and test result
* @i: integer value to subtract
* @v: pointer of type ncpt_atomic_t
*
* Atomically subtracts @i from @v and returns
* true if the result is zero, or false for all
* other cases. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
static __inline__ int ncpt_atomic_sub_and_test(int i, ncpt_atomic_t *v)
{
unsigned char c;
__asm__ __volatile__(
LOCK "subl %2,%0; sete %1"
:"=m" (v->counter), "=qm" (c)
:"ir" (i), "m" (v->counter) : "memory");
return c;
}
/**
* ncpt_atomic_inc - increment atomic variable
* @v: pointer of type ncpt_atomic_t
*
* Atomically increments @v by 1. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
static __inline__ void ncpt_atomic_inc(ncpt_atomic_t *v)
{
__asm__ __volatile__(
LOCK "incl %0"
:"=m" (v->counter)
:"m" (v->counter));
}
/**
* ncpt_atomic_dec - decrement atomic variable
* @v: pointer of type ncpt_atomic_t
*
* Atomically decrements @v by 1. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
static __inline__ void ncpt_atomic_dec(ncpt_atomic_t *v)
{
__asm__ __volatile__(
LOCK "decl %0"
:"=m" (v->counter)
:"m" (v->counter));
}
/**
* ncpt_atomic_dec_and_test - decrement and test
* @v: pointer of type ncpt_atomic_t
*
* Atomically decrements @v by 1 and
* returns true if the result is 0, or false for all other
* cases. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
static __inline__ int ncpt_atomic_dec_and_test(ncpt_atomic_t *v)
{
unsigned char c;
__asm__ __volatile__(
LOCK "decl %0; sete %1"
:"=m" (v->counter), "=qm" (c)
:"m" (v->counter) : "memory");
return c != 0;
}
/**
* ncpt_atomic_inc_and_test - increment and test
* @v: pointer of type ncpt_atomic_t
*
* Atomically increments @v by 1
* and returns true if the result is zero, or false for all
* other cases. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
static __inline__ int ncpt_atomic_inc_and_test(ncpt_atomic_t *v)
{
unsigned char c;
__asm__ __volatile__(
LOCK "incl %0; sete %1"
:"=m" (v->counter), "=qm" (c)
:"m" (v->counter) : "memory");
return c != 0;
}
/**
* ncpt_atomic_add_negative - add and test if negative
* @v: pointer of type ncpt_atomic_t
* @i: integer value to add
*
* Atomically adds @i to @v and returns true
* if the result is negative, or false when
* result is greater than or equal to zero. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
static __inline__ int ncpt_atomic_add_negative(int i, ncpt_atomic_t *v)
{
unsigned char c;
__asm__ __volatile__(
LOCK "addl %2,%0; sets %1"
:"=m" (v->counter), "=qm" (c)
:"ir" (i), "m" (v->counter) : "memory");
return c;
}
/* These are x86-specific, used by some header files */
#define ncpt_atomic_clear_mask(mask, addr) \
__asm__ __volatile__(LOCK "andl %0,%1" \
: : "r" (~(mask)),"m" (*addr) : "memory")
#define ncpt_atomic_set_mask(mask, addr) \
__asm__ __volatile__(LOCK "orl %0,%1" \
: : "r" (mask),"m" (*addr) : "memory")
/* Atomic operations are already serializing on x86 */
#define smp_mb__before_ncpt_atomic_dec() barrier()
#define smp_mb__after_ncpt_atomic_dec() barrier()
#define smp_mb__before_ncpt_atomic_inc() barrier()
#define smp_mb__after_ncpt_atomic_inc() barrier()
#endif

View File

@@ -0,0 +1,62 @@
#ifndef __PRIVATE_ARCH_M68K_ATOMIC__
#define __PRIVATE_ARCH_M68K_ATOMIC__
/* Optimization barrier */
/* The "volatile" is due to gcc bugs */
#define barrier() __asm__ __volatile__("": : :"memory")
/*
* Atomic operations that C can't guarantee us. Useful for
* resource counting etc..
*/
/*
* We do not have SMP m68k systems, so we don't have to deal with that.
*/
typedef struct { int counter; } ncpt_atomic_t;
#define NCPT_ATOMIC_INIT(i) { (i) }
#define ncpt_atomic_read(v) ((v)->counter)
#define ncpt_atomic_set(v, i) (((v)->counter) = i)
static __inline__ void ncpt_atomic_add(int i, ncpt_atomic_t *v)
{
__asm__ __volatile__("addl %1,%0" : "=m" (*v) : "id" (i), "0" (*v));
}
static __inline__ void ncpt_atomic_sub(int i, ncpt_atomic_t *v)
{
__asm__ __volatile__("subl %1,%0" : "=m" (*v) : "id" (i), "0" (*v));
}
static __inline__ void ncpt_atomic_inc(volatile ncpt_atomic_t *v)
{
__asm__ __volatile__("addql #1,%0" : "=m" (*v): "0" (*v));
}
static __inline__ void ncpt_atomic_dec(volatile ncpt_atomic_t *v)
{
__asm__ __volatile__("subql #1,%0" : "=m" (*v): "0" (*v));
}
static __inline__ int ncpt_atomic_dec_and_test(volatile ncpt_atomic_t *v)
{
char c;
__asm__ __volatile__("subql #1,%1; seq %0" : "=d" (c), "=m" (*v): "1" (*v));
return c != 0;
}
#define ncpt_atomic_clear_mask(mask, v) \
__asm__ __volatile__("andl %1,%0" : "=m" (*v) : "id" (~(mask)),"0"(*v))
#define ncpt_atomic_set_mask(mask, v) \
__asm__ __volatile__("orl %1,%0" : "=m" (*v) : "id" (mask),"0"(*v))
/* Atomic operations are already serializing */
#define smp_mb__before_ncpt_atomic_dec() barrier()
#define smp_mb__after_ncpt_atomic_dec() barrier()
#define smp_mb__before_ncpt_atomic_inc() barrier()
#define smp_mb__after_ncpt_atomic_inc() barrier()
#endif /* __ARCH_M68K_ATOMIC __ */

View File

@@ -0,0 +1,212 @@
/*
* Atomic operations that C can't guarantee us. Useful for
* resource counting etc..
*
* But use these as seldom as possible since they are much more slower
* than regular operations.
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* Copyright (C) 1996, 1997, 2000 by Ralf Baechle
*/
#ifndef __PRIVATE_ASM_ATOMIC_H
#define __PRIVATE_ASM_ATOMIC_H
/* Optimization barrier */
/* The "volatile" is due to gcc bugs */
#define barrier() __asm__ __volatile__("": : :"memory")
typedef struct { volatile int counter; } ncpt_atomic_t;
#define NCPT_ATOMIC_INIT(i) { (i) }
/*
* ncpt_atomic_read - read atomic variable
* @v: pointer of type ncpt_atomic_t
*
* Atomically reads the value of @v. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
#define ncpt_atomic_read(v) ((v)->counter)
/*
* ncpt_atomic_set - set atomic variable
* @v: pointer of type ncpt_atomic_t
* @i: required value
*
* Atomically sets the value of @v to @i. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
#define ncpt_atomic_set(v,i) ((v)->counter = (i))
/*
* ... while for MIPS II and better we can use ll/sc instruction. This
* implementation is SMP safe ...
*/
/*
* ncpt_atomic_add - add integer to atomic variable
* @i: integer value to add
* @v: pointer of type ncpt_atomic_t
*
* Atomically adds @i to @v. Note that the guaranteed useful range
* of an ncpt_atomic_t is only 24 bits.
*/
/* Hope that compiler will complain at ll/sc when CPU we are compiling
* (MIPS I) for does not have them...
*/
extern __inline__ void ncpt_atomic_add(int i, ncpt_atomic_t * v)
{
unsigned long temp;
__asm__ __volatile__(
"1: ll %0, %1 # ncpt_atomic_add\n"
" addu %0, %2 \n"
" sc %0, %1 \n"
" beqz %0, 1b \n"
: "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter));
}
/*
* ncpt_atomic_sub - subtract the atomic variable
* @i: integer value to subtract
* @v: pointer of type ncpt_atomic_t
*
* Atomically subtracts @i from @v. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
extern __inline__ void ncpt_atomic_sub(int i, ncpt_atomic_t * v)
{
unsigned long temp;
__asm__ __volatile__(
"1: ll %0, %1 # ncpt_atomic_sub\n"
" subu %0, %2 \n"
" sc %0, %1 \n"
" beqz %0, 1b \n"
: "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter));
}
/*
* Same as above, but return the result value
*/
extern __inline__ int ncpt_atomic_add_return(int i, ncpt_atomic_t * v)
{
unsigned long temp, result;
__asm__ __volatile__(
".set push # ncpt_atomic_add_return\n"
".set noreorder \n"
"1: ll %1, %2 \n"
" addu %0, %1, %3 \n"
" sc %0, %2 \n"
" beqz %0, 1b \n"
" addu %0, %1, %3 \n"
".set pop \n"
: "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter)
: "memory");
return result;
}
extern __inline__ int ncpt_atomic_sub_return(int i, ncpt_atomic_t * v)
{
unsigned long temp, result;
__asm__ __volatile__(
".set push \n"
".set noreorder # ncpt_atomic_sub_return\n"
"1: ll %1, %2 \n"
" subu %0, %1, %3 \n"
" sc %0, %2 \n"
" beqz %0, 1b \n"
" subu %0, %1, %3 \n"
".set pop \n"
: "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter)
: "memory");
return result;
}
#endif
#define ncpt_atomic_dec_return(v) ncpt_atomic_sub_return(1,(v))
#define ncpt_atomic_inc_return(v) ncpt_atomic_add_return(1,(v))
/*
* ncpt_atomic_sub_and_test - subtract value from variable and test result
* @i: integer value to subtract
* @v: pointer of type ncpt_atomic_t
*
* Atomically subtracts @i from @v and returns
* true if the result is zero, or false for all
* other cases. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
#define ncpt_atomic_sub_and_test(i,v) (ncpt_atomic_sub_return((i), (v)) == 0)
/*
* ncpt_atomic_inc_and_test - increment and test
* @v: pointer of type ncpt_atomic_t
*
* Atomically increments @v by 1
* and returns true if the result is zero, or false for all
* other cases. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
#define ncpt_atomic_inc_and_test(v) (ncpt_atomic_inc_return(1, (v)) == 0)
/*
* ncpt_atomic_dec_and_test - decrement by 1 and test
* @v: pointer of type ncpt_atomic_t
*
* Atomically decrements @v by 1 and
* returns true if the result is 0, or false for all other
* cases. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
#define ncpt_atomic_dec_and_test(v) (ncpt_atomic_sub_return(1, (v)) == 0)
/*
* ncpt_atomic_inc - increment atomic variable
* @v: pointer of type ncpt_atomic_t
*
* Atomically increments @v by 1. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
#define ncpt_atomic_inc(v) ncpt_atomic_add(1,(v))
/*
* ncpt_atomic_dec - decrement and test
* @v: pointer of type ncpt_atomic_t
*
* Atomically decrements @v by 1. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
#define ncpt_atomic_dec(v) ncpt_atomic_sub(1,(v))
/*
* ncpt_atomic_add_negative - add and test if negative
* @v: pointer of type ncpt_atomic_t
* @i: integer value to add
*
* Atomically adds @i to @v and returns true
* if the result is negative, or false when
* result is greater than or equal to zero. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*
* Currently not implemented for MIPS.
*/
/* Atomic operations are already serializing */
#define smp_mb__before_ncpt_atomic_dec() barrier()
#define smp_mb__after_ncpt_atomic_dec() barrier()
#define smp_mb__before_ncpt_atomic_inc() barrier()
#define smp_mb__after_ncpt_atomic_inc() barrier()
#endif /* __ASM_ATOMIC_H */

View File

@@ -0,0 +1,193 @@
/*
* Atomic operations that C can't guarantee us. Useful for
* resource counting etc..
*
* But use these as seldom as possible since they are much more slower
* than regular operations.
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* Copyright (C) 1996, 1997, 1999, 2000 by Ralf Baechle
*/
#ifndef _PRIVATE_ASM_ATOMIC_H
#define _PRIVATE_ASM_ATOMIC_H
/* Optimization barrier */
/* The "volatile" is due to gcc bugs */
#define barrier() __asm__ __volatile__("": : :"memory")
typedef struct { volatile int counter; } ncpt_atomic_t;
#define NCPT_ATOMIC_INIT(i) { (i) }
/*
* ncpt_atomic_read - read atomic variable
* @v: pointer of type ncpt_atomic_t
*
* Atomically reads the value of @v. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
#define ncpt_atomic_read(v) ((v)->counter)
/*
* ncpt_atomic_set - set atomic variable
* @v: pointer of type ncpt_atomic_t
* @i: required value
*
* Atomically sets the value of @v to @i. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
#define ncpt_atomic_set(v,i) ((v)->counter = (i))
extern __inline__ void ncpt_atomic_add(int i, volatile ncpt_atomic_t * v)
{
unsigned long temp;
__asm__ __volatile__(
"1:\tll\t%0,%1\t\t\t# ncpt_atomic_add\n\t"
"addu\t%0,%2\n\t"
"sc\t%0,%1\n\t"
"beqz\t%0,1b"
: "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter));
}
/*
* ncpt_atomic_sub - subtract the atomic variable
* @i: integer value to subtract
* @v: pointer of type ncpt_atomic_t
*
* Atomically subtracts @i from @v. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
extern __inline__ void ncpt_atomic_sub(int i, volatile ncpt_atomic_t * v)
{
unsigned long temp;
__asm__ __volatile__(
"1:\tll\t%0,%1\t\t\t# ncpt_atomic_sub\n\t"
"subu\t%0,%2\n\t"
"sc\t%0,%1\n\t"
"beqz\t%0,1b"
: "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter));
}
/*
* Same as above, but return the result value
*/
extern __inline__ int ncpt_atomic_add_return(int i, ncpt_atomic_t * v)
{
unsigned long temp, result;
__asm__ __volatile__(
".set\tnoreorder\t\t\t# ncpt_atomic_add_return\n"
"1:\tll\t%1,%2\n\t"
"addu\t%0,%1,%3\n\t"
"sc\t%0,%2\n\t"
"beqz\t%0,1b\n\t"
"addu\t%0,%1,%3\n\t"
".set\treorder"
: "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter)
: "memory");
return result;
}
extern __inline__ int ncpt_atomic_sub_return(int i, ncpt_atomic_t * v)
{
unsigned long temp, result;
__asm__ __volatile__(
".set\tnoreorder\t\t\t# ncpt_atomic_sub_return\n"
"1:\tll\t%1,%2\n\t"
"subu\t%0,%1,%3\n\t"
"sc\t%0,%2\n\t"
"beqz\t%0,1b\n\t"
"subu\t%0,%1,%3\n\t"
".set\treorder"
: "=&r" (result), "=&r" (temp), "=m" (v->counter)
: "Ir" (i), "m" (v->counter)
: "memory");
return result;
}
#define ncpt_atomic_dec_return(v) ncpt_atomic_sub_return(1,(v))
#define ncpt_atomic_inc_return(v) ncpt_atomic_add_return(1,(v))
/*
* ncpt_atomic_sub_and_test - subtract value from variable and test result
* @i: integer value to subtract
* @v: pointer of type ncpt_atomic_t
*
* Atomically subtracts @i from @v and returns
* true if the result is zero, or false for all
* other cases. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
#define ncpt_atomic_sub_and_test(i,v) (ncpt_atomic_sub_return((i), (v)) == 0)
/*
* ncpt_atomic_inc_and_test - increment and test
* @v: pointer of type ncpt_atomic_t
*
* Atomically increments @v by 1
* and returns true if the result is zero, or false for all
* other cases. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
* ncpt_atomic_inc_and_test is currently not implemented for mips64.
*/
/*
* ncpt_atomic_dec_and_test - decrement by 1 and test
* @v: pointer of type ncpt_atomic_t
*
* Atomically decrements @v by 1 and
* returns true if the result is 0, or false for all other
* cases. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
#define ncpt_atomic_dec_and_test(v) (ncpt_atomic_sub_return(1, (v)) == 0)
/*
* ncpt_atomic_inc - increment atomic variable
* @v: pointer of type ncpt_atomic_t
*
* Atomically increments @v by 1. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
#define ncpt_atomic_inc(v) ncpt_atomic_add(1,(v))
/*
* ncpt_atomic_dec - decrement and test
* @v: pointer of type ncpt_atomic_t
*
* Atomically decrements @v by 1. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*/
#define ncpt_atomic_dec(v) ncpt_atomic_sub(1,(v))
/*
* ncpt_atomic_add_negative - add and test if negative
* @v: pointer of type ncpt_atomic_t
* @i: integer value to add
*
* Atomically adds @i to @v and returns true
* if the result is negative, or false when
* result is greater than or equal to zero. Note that the guaranteed
* useful range of an ncpt_atomic_t is only 24 bits.
*
* ncpt_atomic_add_negative is currently not implemented for mips64.
*/
/* Atomic operations are already serializing */
#define smp_mb__before_ncpt_atomic_dec() barrier()
#define smp_mb__after_ncpt_atomic_dec() barrier()
#define smp_mb__before_ncpt_atomic_inc() barrier()
#define smp_mb__after_ncpt_atomic_inc() barrier()
#endif /* _ASM_ATOMIC_H */

View File

@@ -0,0 +1,16 @@
#ifndef __PRIVATE_LIBNCP_NONE_ATOMIC_H__
#define __PRIVATE_LIBNCP_NONE_ATOMIC_H__
typedef struct { int counter; } ncpt_atomic_t;
#define NCPT_ATOMIC_INIT(i) { (i) }
#define ncpt_atomic_read(v) ((v)->counter)
#define ncpt_atomic_set(v,i) (((v)->counter) = (i))
#define ncpt_atomic_add(i,v) (((v)->counter) += (i))
#define ncpt_atomic_sub(i,v) (((v)->counter) -= (i))
#define ncpt_atomic_inc(v) ((v)->counter++)
#define ncpt_atomic_dec(v) ((v)->counter--)
#define ncpt_atomic_dec_and_test(v) (!(--(v)->counter))
#endif /* __PRIVATE_LIBNCP_NONE_ATOMIC_H__ */

View File

@@ -0,0 +1,143 @@
/*
* BK Id: SCCS/s.atomic.h 1.8 05/17/01 18:14:24 cort
*/
/*
* PowerPC atomic operations
*/
#ifndef _ASM_PPC_ATOMIC_H_
#define _ASM_PPC_ATOMIC_H_
/*
* Memory barrier.
* The sync instruction guarantees that all memory accesses initiated
* by this processor have been performed (with respect to all other
* mechanisms that access memory). The eieio instruction is a barrier
* providing an ordering (separately) for (a) cacheable stores and (b)
* loads and stores to non-cacheable memory (e.g. I/O devices).
*
* mb() prevents loads and stores being reordered across this point.
* rmb() prevents loads being reordered across this point.
* wmb() prevents stores being reordered across this point.
*
* We can use the eieio instruction for wmb, but since it doesn't
* give any ordering guarantees about loads, we have to use the
* stronger but slower sync instruction for mb and rmb.
*/
#define mb() __asm__ __volatile__ ("sync" : : : "memory")
#define rmb() __asm__ __volatile__ ("sync" : : : "memory")
#define wmb() __asm__ __volatile__ ("eieio" : : : "memory")
#define smp_mb() mb()
#define smp_rmb() rmb()
#define smp_wmb() wmb()
typedef struct { volatile int counter; } ncpt_atomic_t;
#define NCPT_ATOMIC_INIT(i) { (i) }
#define ncpt_atomic_read(v) ((v)->counter)
#define ncpt_atomic_set(v,i) (((v)->counter) = (i))
extern void ncpt_atomic_clear_mask(unsigned long mask, unsigned long *addr);
extern void ncpt_atomic_set_mask(unsigned long mask, unsigned long *addr);
static __inline__ int ncpt_atomic_add_return(int a, ncpt_atomic_t *v)
{
int t;
__asm__ __volatile__("\n\
1: lwarx %0,0,%3\n\
add %0,%2,%0\n\
stwcx. %0,0,%3\n\
bne- 1b"
: "=&r" (t), "=m" (v->counter)
: "r" (a), "r" (v), "m" (v->counter)
: "cc");
return t;
}
static __inline__ int ncpt_atomic_sub_return(int a, ncpt_atomic_t *v)
{
int t;
__asm__ __volatile__("\n\
1: lwarx %0,0,%3\n\
subf %0,%2,%0\n\
stwcx. %0,0,%3\n\
bne- 1b"
: "=&r" (t), "=m" (v->counter)
: "r" (a), "r" (v), "m" (v->counter)
: "cc");
return t;
}
static __inline__ int ncpt_atomic_inc_return(ncpt_atomic_t *v)
{
int t;
__asm__ __volatile__("\n\
1: lwarx %0,0,%2\n\
addic %0,%0,1\n\
stwcx. %0,0,%2\n\
bne- 1b"
: "=&r" (t), "=m" (v->counter)
: "r" (v), "m" (v->counter)
: "cc");
return t;
}
static __inline__ int ncpt_atomic_dec_return(ncpt_atomic_t *v)
{
int t;
__asm__ __volatile__("\n\
1: lwarx %0,0,%2\n\
addic %0,%0,-1\n\
stwcx. %0,0,%2\n\
bne 1b"
: "=&r" (t), "=m" (v->counter)
: "r" (v), "m" (v->counter)
: "cc");
return t;
}
#define ncpt_atomic_add(a, v) ((void) ncpt_atomic_add_return((a), (v)))
#define ncpt_atomic_sub(a, v) ((void) ncpt_atomic_sub_return((a), (v)))
#define ncpt_atomic_sub_and_test(a, v) (ncpt_atomic_sub_return((a), (v)) == 0)
#define ncpt_atomic_inc(v) ((void) ncpt_atomic_inc_return((v)))
#define ncpt_atomic_dec(v) ((void) ncpt_atomic_dec_return((v)))
#define ncpt_atomic_dec_and_test(v) (ncpt_atomic_dec_return((v)) == 0)
/*
* Atomically test *v and decrement if it is greater than 0.
* The function returns the old value of *v minus 1.
*/
static __inline__ int ncpt_atomic_dec_if_positive(ncpt_atomic_t *v)
{
int t;
__asm__ __volatile__("\n"
"1: lwarx %0,0,%2\n"
" addic. %0,%0,-1\n"
" blt 2f\n"
" stwcx. %0,0,%2\n"
" bne 1b\n"
"2:"
: "=&r" (t), "=m" (v->counter)
: "r" (&v->counter), "m" (v->counter)
: "cc");
return t;
}
#define smp_mb__before_ncpt_atomic_dec() smp_mb()
#define smp_mb__after_ncpt_atomic_dec() smp_mb()
#define smp_mb__before_ncpt_atomic_inc() smp_mb()
#define smp_mb__after_ncpt_atomic_inc() smp_mb()
#endif /* _ASM_PPC_ATOMIC_H_ */

83
include/private/libintl.h Normal file
View File

@@ -0,0 +1,83 @@
/* Convenience header for conditional use of GNU <libintl.h>.
Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifndef __PRIVATE_LIBINTL_H__
#define __PRIVATE_LIBINTL_H__
#include "config.h"
/* NLS can be disabled through the configure --disable-nls option. */
#if ENABLE_NLS
/* Get declarations of GNU message catalog functions. */
# include <libintl.h>
#else
/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
chokes if dcgettext is defined as a macro. So include it now, to make
later inclusions of <locale.h> a NOP. We don't include <libintl.h>
as well because people using "gettext.h" will not include <libintl.h>,
and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
is OK. */
#if defined(__sun)
# include <locale.h>
#endif
/* Disabled NLS.
The casts to 'const char *' serve the purpose of producing warnings
for invalid uses of the value returned from these functions.
On pre-ANSI systems without 'const', the config.h file is supposed to
contain "#define const". */
# define gettext(Msgid) ((const char *) (Msgid))
# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
# define ngettext(Msgid1, Msgid2, N) \
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
# define dngettext(Domainname, Msgid1, Msgid2, N) \
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
# define textdomain(Domainname) ((const char *) (Domainname))
# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
#endif
/* A pseudo function call that serves as a marker for the automated
extraction of messages, but does not call gettext(). The run-time
translation is done at a different place in the code.
The argument, String, should be a literal string. Concatenated strings
and other string expressions won't work.
The macro's expansion is not parenthesized, so that it is suitable as
initializer for static 'char[]' or 'const char[]' variables. */
#define gettext_noop(String) String
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
#ifndef HAVE_SETLOCALE
#define setlocale(X,Y) (Y)
#endif
#ifndef LC_ALL
#define LC_ALL 6 /* It is used when you have setlocale, but not locale.h header... */
#endif
#endif /* __PRIVATE_LIBINTL_H__ */

View File

@@ -0,0 +1,6 @@
#ifndef __PRIVATE_LIBNCP_ATOMIC_H__
#define __PRIVATE_LIBNCP_ATOMIC_H__
#include "private/asm-i386/atomic.h"
#endif /* __PRIVATE_LIBNCP_ATOMIC_H__ */

View File

@@ -0,0 +1,6 @@
#ifndef __PRIVATE_LIBNCP_ATOMIC_H__
#define __PRIVATE_LIBNCP_ATOMIC_H__
#include "private/asm-@ncphost@/atomic.h"
#endif /* __PRIVATE_LIBNCP_ATOMIC_H__ */

View File

@@ -0,0 +1,314 @@
/* original came from bits/libc-lock.h in libc-2.1.1 */
/* libc-internal interface for mutex locks. LinuxThreads version.
Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef _PRIVATE_LIBNCP_LOCK_H
#define _PRIVATE_LIBNCP_LOCK_H 1
#ifdef _REENTRANT
#include <pthread.h>
typedef pthread_mutex_t ncpt_mutex_t;
typedef pthread_once_t ncpt_once_t;
typedef pthread_key_t ncpt_key_t;
#define NCPT_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
/* Initialize the named lock variable, leaving it in a consistent, unlocked
state. */
#define ncpt_mutex_init(NAME) \
(pthread_mutex_init ? pthread_mutex_init (NAME, NULL) : 0);
/* Same as last but this time we initialize a recursive mutex. */
#define ncpt_mutex_init_recursive(NAME) \
do { \
if (pthread_mutex_init && pthread_mutexattr_init && \
pthread_mutexattr_settype && pthread_mutexattr_destroy) \
{ \
pthread_mutexattr_t __attr; \
pthread_mutexattr_init (&__attr); \
pthread_mutexattr_settype (&__attr, PTHREAD_MUTEX_RECURSIVE_NP); \
pthread_mutex_init (NAME, &__attr); \
pthread_mutexattr_destroy (&__attr); \
} \
} while (0);
/* Finalize the named lock variable, which must be locked. It cannot be
used again until __libc_lock_init is called again on it. This must be
called on a lock variable before the containing storage is reused. */
#define ncpt_mutex_destroy(NAME) \
(pthread_mutex_destroy ? pthread_mutex_destroy (NAME) : 0);
/* Lock the named lock variable. */
#define ncpt_mutex_lock(NAME) \
(pthread_mutex_lock ? pthread_mutex_lock (NAME) : 0);
/* Lock the recursive named lock variable. */
#define ncpt_mutex_lock_recursive(NAME) ncpt_mutex_lock (NAME)
/* Try to lock the named lock variable. */
#define ncpt_mutex_trylock(NAME) \
(pthread_mutex_trylock ? pthread_mutex_trylock (NAME) : 0)
/* Try to lock the recursive named lock variable. */
#define ncpt_mutex_trylock_recursive(NAME) ncpt_mutex_trylock (NAME)
/* Unlock the named lock variable. */
#define ncpt_mutex_unlock(NAME) \
(pthread_mutex_unlock ? pthread_mutex_unlock (NAME) : 0);
/* Unlock the recursive named lock variable. */
#define ncpt_mutex_unlock_recursive(NAME) ncpt_mutex_unlock (NAME)
#define NCPT_ONCE_INIT PTHREAD_ONCE_INIT
/* Call handler iff the first call. */
#define ncpt_once(ONCE_CONTROL, INIT_FUNCTION) \
do { \
if (pthread_once) \
pthread_once ((ONCE_CONTROL), (INIT_FUNCTION)); \
else if (*(ONCE_CONTROL) == NCPT_ONCE_INIT) { \
INIT_FUNCTION (); \
*(ONCE_CONTROL) = 1; \
} \
} while (0)
/* Start critical region with cleanup. */
#define __libc_cleanup_region_start(FCT, ARG) \
{ struct _pthread_cleanup_buffer _buffer; \
int _avail = _pthread_cleanup_push_defer != NULL; \
if (_avail) { \
_pthread_cleanup_push_defer (&_buffer, (FCT), (ARG)); \
}
/* End critical region with cleanup. */
#define __libc_cleanup_region_end(DOIT) \
if (_avail) { \
_pthread_cleanup_pop_restore (&_buffer, (DOIT)); \
} \
}
/* Sometimes we have to exit the block in the middle. */
#define __libc_cleanup_end(DOIT) \
if (_avail) { \
_pthread_cleanup_pop_restore (&_buffer, (DOIT)); \
}
#if 0
/* Create thread-specific key. */
static inline int ncpt_key_create(ncpt_key_t* KEY, void (*DESTRUCTOR)(void*)) {
ncpt_key_t k;
if (pthread_key_create)
return pthread_key_create(KEY, DESTRUCTOR);
k = (ncpt_key_t)malloc(sizeof(void*));
if (!k)
return ENOMEM;
*(void**)k = NULL;
*KEY = k;
return 0;
}
/* Get thread-specific data. */
static inline void* ncpt_getspecific(ncpt_key_t KEY) {
if (pthread_getspecific)
return pthread_getspecific(KEY);
if (KEY)
return *(void**)KEY;
return NULL;
}
/* Set thread-specific data. */
static inline int ncpt_setspecific(ncpt_key_t KEY, const void* VALUE) {
if (pthread_setspecific)
return pthread_setspecific(KEY, VALUE);
if (!KEY)
return EINVAL;
*(void**)KEY = VALUE;
return 0;
}
#endif
/* Register handlers to execute before and after `fork'. */
#define ncpt_atfork(PREPARE, PARENT, CHILD) \
(pthread_atfork ? pthread_atfork (PREPARE, PARENT, CHILD) : 0)
/* Make the pthread functions weak so that we can elide them from
single-threaded processes. */
#ifndef __NO_WEAK_PTHREAD_ALIASES
# ifdef weak_extern
weak_extern (pthread_mutex_init)
weak_extern (pthread_mutex_destroy)
weak_extern (pthread_mutex_lock)
weak_extern (pthread_mutex_trylock)
weak_extern (pthread_mutex_unlock)
weak_extern (pthread_mutexattr_init)
weak_extern (pthread_mutexattr_destroy)
weak_extern (pthread_mutexattr_settype)
weak_extern (pthread_key_create)
weak_extern (pthread_setspecific)
weak_extern (pthread_getspecific)
weak_extern (pthread_once)
weak_extern (pthread_initialize)
weak_extern (pthread_atfork)
weak_extern (_pthread_cleanup_push_defer)
weak_extern (_pthread_cleanup_pop_restore)
# else
# pragma weak pthread_mutex_init
# pragma weak pthread_mutex_destroy
# pragma weak pthread_mutex_lock
# pragma weak pthread_mutex_trylock
# pragma weak pthread_mutex_unlock
# pragma weak pthread_mutexattr_init
# pragma weak pthread_mutexattr_destroy
# pragma weak pthread_mutexattr_settype
# pragma weak pthread_key_create
# pragma weak pthread_setspecific
# pragma weak pthread_getspecific
# pragma weak pthread_once
# pragma weak pthread_initialize
# pragma weak pthread_atfork
# pragma weak _pthread_cleanup_push_defer
# pragma weak _pthread_cleanup_pop_restore
# endif
#endif
#else /* _REENTRANT */
typedef unsigned int ncpt_mutex_t;
typedef unsigned int ncpt_once_t;
typedef void** ncpt_key_t;
#define NCPT_MUTEX_INITIALIZER (0)
/* Initialize the named lock variable, leaving it in a consistent, unlocked
state. */
static inline int ncpt_mutex_init(ncpt_mutex_t* mutex) {
return 0;
(void)mutex;
}
/* Same as last but this time we initialize a recursive mutex. */
static inline int ncpt_mutex_init_recursive(ncpt_mutex_t* mutex) {
return 0;
(void)mutex;
}
/* Finalize the named lock variable, which must be locked. It cannot be
used again until __libc_lock_init is called again on it. This must be
called on a lock variable before the containing storage is reused. */
static inline int ncpt_mutex_destroy(ncpt_mutex_t* mutex) {
return 0;
(void)mutex;
}
/* Lock the named lock variable. */
static inline int ncpt_mutex_lock(ncpt_mutex_t* mutex) {
return 0;
(void)mutex;
}
/* Lock the recursive named lock variable. */
#define ncpt_mutex_lock_recursive(NAME) ncpt_mutex_lock(NAME)
/* Try to lock the named lock variable. */
static inline int ncpt_mutex_trylock(ncpt_mutex_t* mutex) {
return 0;
(void)mutex;
}
/* Try to lock the recursive named lock variable. */
#define ncpt_mutex_trylock_recursive(NAME) ncpt_mutex_trylock(NAME)
/* Unlock the named lock variable. */
static inline int ncpt_mutex_unlock(ncpt_mutex_t* mutex) {
return 0;
(void)mutex;
}
/* Unlock the recursive named lock variable. */
#define ncpt_mutex_unlock_recursive(NAME) ncpt_mutex_unlock(NAME)
#define NCPT_ONCE_INIT (0)
/* Call handler iff the first call. */
#define ncpt_once(ONCE_CONTROL, INIT_FUNCTION) \
do { \
if (*(ONCE_CONTROL) == NCPT_ONCE_INIT) { \
INIT_FUNCTION (); \
*(ONCE_CONTROL) = 1; \
} \
} while (0)
/* Start critical region with cleanup. */
#define __libc_cleanup_region_start(FCT, ARG) \
{ struct _pthread_cleanup_buffer _buffer; \
int _avail = _pthread_cleanup_push_defer != NULL; \
if (_avail) { \
_pthread_cleanup_push_defer (&_buffer, (FCT), (ARG)); \
}
/* End critical region with cleanup. */
#define __libc_cleanup_region_end(DOIT) \
if (_avail) { \
_pthread_cleanup_pop_restore (&_buffer, (DOIT)); \
} \
}
/* Sometimes we have to exit the block in the middle. */
#define __libc_cleanup_end(DOIT) \
if (_avail) { \
_pthread_cleanup_pop_restore (&_buffer, (DOIT)); \
}
#if 0
/* Create thread-specific key. */
static inline int ncpt_key_create(ncpt_key_t* KEY, void (*DESTRUCTOR)(void*)) {
ncpt_key_t k = (ncpt_key_t)malloc(sizeof(void*));
if (!k)
return ENOMEM;
*k = NULL;
*KEY = k;
return 0;
}
/* Get thread-specific data. */
static inline void* ncpt_getspecific(ncpt_key_t KEY) {
return KEY ? *KEY : NULL;
}
/* Set thread-specific data. */
static inline int ncpt_setspecific(ncpt_key_t KEY, const void* VALUE) {
if (!KEY)
return EINVAL;
*KEY = VALUE;
return 0;
}
#endif
/* Register handlers to execute before and after `fork'. */
#define ncpt_atfork(PREPARE, PARENT, CHILD) (0)
#endif /* _REENTRANT */
#endif /* private/libncp-lock.h */

97
include/private/list.h Normal file
View File

@@ -0,0 +1,97 @@
/* this code was borrowed from Linux-kernel 2.3.6 */
#ifndef NCP_LINUX_LIST_H
#define NCP_LINUX_LIST_H
/*
* Simple doubly linked list implementation.
*
* Some of the internal functions ("__xxx") are useful when
* manipulating whole lists rather than single entries, as
* sometimes we already know the next/prev entries and we can
* generate better code by using them directly rather than
* using the generic single-entry routines.
*/
struct list_head {
struct list_head *next, *prev;
};
#define LIST_HEAD(name) \
struct list_head name = { &name, &name }
#define INIT_LIST_HEAD(ptr) do { \
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
} while (0)
/*
* Insert a new entry between two known consecutive entries.
*
* This is only for internal list manipulation where we know
* the prev/next entries already!
*/
static __inline__ void __list_add(struct list_head * new,
struct list_head * prev,
struct list_head * next)
{
next->prev = new;
new->next = next;
new->prev = prev;
prev->next = new;
}
/*
* Insert a new entry after the specified head..
*/
static __inline__ void list_add(struct list_head *new, struct list_head *head)
{
__list_add(new, head, head->next);
}
/*
* Delete a list entry by making the prev/next entries
* point to each other.
*
* This is only for internal list manipulation where we know
* the prev/next entries already!
*/
static __inline__ void __list_del(struct list_head * prev,
struct list_head * next)
{
next->prev = prev;
prev->next = next;
}
static __inline__ void list_del(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
INIT_LIST_HEAD(entry);
}
static __inline__ int list_empty(struct list_head *head)
{
return head->next == head;
}
/*
* Splice in "list" into "head"
*/
static __inline__ void list_splice(struct list_head *list, struct list_head *head)
{
struct list_head *first = list->next;
if (first != list) {
struct list_head *last = list->prev;
struct list_head *at = head->next;
first->prev = head;
head->next = first;
last->next = at;
at->prev = last;
}
}
#define list_entry(ptr, type, member) \
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
#endif /*ndef NCP_LINUX_LIST_H */

39
include/private/ncp-new.h Normal file
View File

@@ -0,0 +1,39 @@
#ifndef _LINUX_NCP_NEW_H
#define _LINUX_NCP_NEW_H
#include <ncp/kernel/types.h>
#define NCP_MINOR 222
#define NCP_IOC_NEWCONN 0xDDDD0001 /* ncp_ioc_newconn */
#define NCP_IOC_DELCONN 0xDDDD0002 /* none */
#define NCP_IOC_REQUEST_REPLY 0xDDDD0003 /* ncp_ioc_request_reply */
#define NCP_MAX_RPC_TIMEOUT 100
#define DDPRINTK(X...)
#define DPRINTK(X...)
struct ncp_ioc_newconn {
int fd;
#define NCP_FLAGS_SIGN_NEGOTIATED 0x0001
#define NCP_FLAGS_SIGN_ACTIVE 0x0002
int flags;
int sequence;
int connection;
struct ncp_sign_init sign;
};
struct ncp_ioc_request_reply {
unsigned int function;
struct {
unsigned int size;
u_int8_t* addr;
} request;
struct {
unsigned int size;
u_int8_t* addr;
} reply;
};
#endif

23
include/private/ncp_fs.h Normal file
View File

@@ -0,0 +1,23 @@
#ifndef _PRIVATE_NCP_FS_H
#define _PRIVATE_NCP_FS_H
#include <ncp/kernel/types.h>
struct ncp_fs_info_v2 {
int version;
unsigned long mounted_uid;
unsigned int connection;
unsigned int buffer_size;
unsigned int volume_number;
u_int32_t directory_id;
u_int32_t dummy1;
u_int32_t dummy2;
u_int32_t dummy3;
};
#define NCP_GET_FS_INFO_VERSION_V2 (2)
#define NCP_IOC_GET_FS_INFO_V2 _IOWR('n', 4, struct ncp_fs_info_v2)
#endif