lkml.org 
[lkml]   [2001]   [Aug]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
OK, tried it, twice, still doesn't wan't to compile the second time.
Followed your instructions, twice. Then I deleted the directory,
untarred again, reconfigured the kernel from scratch, made it the
first pass. then it would not recompile after I ran 'make xconfig',
saved, and tried to recompile with 'make install'. then I ran 'make
mrproper', 'make xconfig', 'make dep', make install ----- broke again
with the following perplexing errors.

all I can tell for sure is that the compiler doewn't seem to have a
definition for FASTCALL.

thank you for your input.

Fred

______________________________________________________________

[root@bits linux]# make install
scripts/split-include include/linux/autoconf.h include/config
gcc -D__KERNEL__ -I/b2/sw/linux-2.4.9/include -Wall
-Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer
-fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2
-march=k6 -c -o init/main.o init/main.c
In file included from /b2/sw/linux-2.4.9/include/linux/fs.h:19,
from
/b2/sw/linux-2.4.9/include/linux/capability.h:17,
from /b2/sw/linux-2.4.9/include/linux/binfmts.h:5,
from /b2/sw/linux-2.4.9/include/linux/sched.h:9,
from /b2/sw/linux-2.4.9/include/linux/mm.h:4,
from /b2/sw/linux-2.4.9/include/linux/slab.h:14,
from /b2/sw/linux-2.4.9/include/linux/proc_fs.h:5,
from init/main.c:15:
/b2/sw/linux-2.4.9/include/linux/dcache.h: In function `dget':
/b2/sw/linux-2.4.9/include/linux/dcache.h:244: warning: implicit
declaration of function `printk'
In file included from /b2/sw/linux-2.4.9/include/asm/semaphore.h:39,
from /b2/sw/linux-2.4.9/include/linux/fs.h:198,
from
/b2/sw/linux-2.4.9/include/linux/capability.h:17,
from /b2/sw/linux-2.4.9/include/linux/binfmts.h:5,
from /b2/sw/linux-2.4.9/include/linux/sched.h:9,
from /b2/sw/linux-2.4.9/include/linux/mm.h:4,
from /b2/sw/linux-2.4.9/include/linux/slab.h:14,
from /b2/sw/linux-2.4.9/include/linux/proc_fs.h:5,
from init/main.c:15:
/b2/sw/linux-2.4.9/include/asm/system.h: At top level:
/b2/sw/linux-2.4.9/include/asm/system.h:12: parse error before `('
In file included from /b2/sw/linux-2.4.9/include/linux/rwsem.h:27,
from /b2/sw/linux-2.4.9/include/asm/semaphore.h:42,
from /b2/sw/linux-2.4.9/include/linux/fs.h:198,
from
/b2/sw/linux-2.4.9/include/linux/capability.h:17,
from /b2/sw/linux-2.4.9/include/linux/binfmts.h:5,
from /b2/sw/linux-2.4.9/include/linux/sched.h:9,
from /b2/sw/linux-2.4.9/include/linux/mm.h:4,
from /b2/sw/linux-2.4.9/include/linux/slab.h:14,
from /b2/sw/linux-2.4.9/include/linux/proc_fs.h:5,
from init/main.c:15:
/b2/sw/linux-2.4.9/include/asm/rwsem.h:46: parse error before `('
/b2/sw/linux-2.4.9/include/asm/rwsem.h:47: parse error before `('
/b2/sw/linux-2.4.9/include/asm/rwsem.h:48: parse error before `('
In file included from
/b2/sw/linux-2.4.9/include/linux/capability.h:17,
from /b2/sw/linux-2.4.9/include/linux/binfmts.h:5,
from /b2/sw/linux-2.4.9/include/linux/sched.h:9,
from /b2/sw/linux-2.4.9/include/linux/mm.h:4,
from /b2/sw/linux-2.4.9/include/linux/slab.h:14,
from /b2/sw/linux-2.4.9/include/linux/proc_fs.h:5,
from init/main.c:15:
/b2/sw/linux-2.4.9/include/linux/fs.h: In function `put_bh':
/b2/sw/linux-2.4.9/include/linux/fs.h:1082: warning: implicit
declaration of function `barrier'
/b2/sw/linux-2.4.9/include/linux/fs.h: At top level:
/b2/sw/linux-2.4.9/include/linux/fs.h:1123: parse error before `('
/b2/sw/linux-2.4.9/include/linux/fs.h:1124: parse error before `('
/b2/sw/linux-2.4.9/include/linux/fs.h: In function
`mark_buffer_dirty_inode':
/b2/sw/linux-2.4.9/include/linux/fs.h:1146: warning: implicit
declaration of function `mark_buffer_dirty'
In file included from /b2/sw/linux-2.4.9/include/linux/mm.h:4,
from /b2/sw/linux-2.4.9/include/linux/slab.h:14,
from /b2/sw/linux-2.4.9/include/linux/proc_fs.h:5,
from init/main.c:15:
/b2/sw/linux-2.4.9/include/linux/sched.h: At top level:
/b2/sw/linux-2.4.9/include/linux/sched.h:153: parse error before `('
In file included from /b2/sw/linux-2.4.9/include/linux/mm.h:4,
from /b2/sw/linux-2.4.9/include/linux/slab.h:14,
from /b2/sw/linux-2.4.9/include/linux/proc_fs.h:5,
from init/main.c:15:
/b2/sw/linux-2.4.9/include/linux/sched.h:551: parse error before `('
/b2/sw/linux-2.4.9/include/linux/sched.h:552: parse error before `('
/b2/sw/linux-2.4.9/include/linux/sched.h:553: parse error before `('
/b2/sw/linux-2.4.9/include/linux/sched.h:554: parse error before `('
/b2/sw/linux-2.4.9/include/linux/sched.h:556: parse error before `('
/b2/sw/linux-2.4.9/include/linux/sched.h:557: parse error before `('
/b2/sw/linux-2.4.9/include/linux/sched.h:559: parse error before `('
/b2/sw/linux-2.4.9/include/linux/sched.h:721: parse error before `('
/b2/sw/linux-2.4.9/include/linux/sched.h: In function `mmdrop':
/b2/sw/linux-2.4.9/include/linux/sched.h:725: warning: implicit
declaration of function `__mmdrop'
/b2/sw/linux-2.4.9/include/linux/sched.h: At top level:
/b2/sw/linux-2.4.9/include/linux/sched.h:757: parse error before `('
/b2/sw/linux-2.4.9/include/linux/sched.h:758: parse error before `('
/b2/sw/linux-2.4.9/include/linux/sched.h:759: parse error before `('
In file included from /b2/sw/linux-2.4.9/include/linux/slab.h:14,
from /b2/sw/linux-2.4.9/include/linux/proc_fs.h:5,
from init/main.c:15:
/b2/sw/linux-2.4.9/include/linux/mm.h:383: parse error before `('
/b2/sw/linux-2.4.9/include/linux/mm.h:384: parse error before `('
/b2/sw/linux-2.4.9/include/linux/mm.h: In function `alloc_pages':
/b2/sw/linux-2.4.9/include/linux/mm.h:394: warning: implicit
declaration of function
`_alloc_pages'/b2/sw/linux-2.4.9/include/linux/mm.h:394: warning:
return makes pointer from integer without a cast
/b2/sw/linux-2.4.9/include/linux/mm.h: At top level:
/b2/sw/linux-2.4.9/include/linux/mm.h:399: parse error before `('
/b2/sw/linux-2.4.9/include/linux/mm.h:400: parse error before `('
/b2/sw/linux-2.4.9/include/linux/mm.h:416: parse error before `('
/b2/sw/linux-2.4.9/include/linux/mm.h:417: parse error before `('
/b2/sw/linux-2.4.9/include/linux/mm.h:438: parse error before `('
/b2/sw/linux-2.4.9/include/linux/mm.h:439: parse error before `('
/b2/sw/linux-2.4.9/include/linux/mm.h: In function `pmd_alloc':
/b2/sw/linux-2.4.9/include/linux/mm.h:455: warning: implicit
declaration of function `__pmd_alloc'
/b2/sw/linux-2.4.9/include/linux/mm.h:455: warning: return makes
pointer from integer without a cast
In file included from /b2/sw/linux-2.4.9/include/linux/highmem.h:5,
from /b2/sw/linux-2.4.9/include/linux/pagemap.h:16,
from /b2/sw/linux-2.4.9/include/linux/locks.h:8,
from
/b2/sw/linux-2.4.9/include/linux/devfs_fs_kernel.h:6,
from init/main.c:16:
/b2/sw/linux-2.4.9/include/asm/pgalloc.h: In function `get_pgd_slow':
/b2/sw/linux-2.4.9/include/asm/pgalloc.h:53: warning: implicit
declaration of function `__get_free_pages'
/b2/sw/linux-2.4.9/include/asm/pgalloc.h: In function `free_pgd_slow':
/b2/sw/linux-2.4.9/include/asm/pgalloc.h:93: warning: implicit
declaration of function `free_pages'In file included from
/b2/sw/linux-2.4.9/include/linux/irq.h:57,
from /b2/sw/linux-2.4.9/include/asm/hardirq.h:6,
from /b2/sw/linux-2.4.9/include/linux/interrupt.h:45,
from
/b2/sw/linux-2.4.9/include/linux/netdevice.h:424,
from /b2/sw/linux-2.4.9/include/net/ip.h:29,
from /b2/sw/linux-2.4.9/include/net/checksum.h:31,
from /b2/sw/linux-2.4.9/include/linux/raid/md.h:34,
from init/main.c:24:
/b2/sw/linux-2.4.9/include/asm/hw_irq.h: At top level:
/b2/sw/linux-2.4.9/include/asm/hw_irq.h:78: parse error before `('
In file included from
/b2/sw/linux-2.4.9/include/linux/netdevice.h:424,
from /b2/sw/linux-2.4.9/include/net/ip.h:29,
from /b2/sw/linux-2.4.9/include/net/checksum.h:31,
from /b2/sw/linux-2.4.9/include/linux/raid/md.h:34,
from init/main.c:24:
/b2/sw/linux-2.4.9/include/linux/interrupt.h:77: parse error before
`('
/b2/sw/linux-2.4.9/include/linux/interrupt.h:78: parse error before
`('
/b2/sw/linux-2.4.9/include/linux/interrupt.h:154: parse error before
`('
/b2/sw/linux-2.4.9/include/linux/interrupt.h: In function
`tasklet_schedule':
/b2/sw/linux-2.4.9/include/linux/interrupt.h:159: warning: implicit
declaration of function `__tasklet_schedule'
/b2/sw/linux-2.4.9/include/linux/interrupt.h: At top level:
/b2/sw/linux-2.4.9/include/linux/interrupt.h:162: parse error before
`('
/b2/sw/linux-2.4.9/include/linux/interrupt.h: In function
`tasklet_hi_schedule':
/b2/sw/linux-2.4.9/include/linux/interrupt.h:167: warning: implicit
declaration of function `__tasklet_hi_schedule'
In file included from /b2/sw/linux-2.4.9/include/net/ip.h:29,
from /b2/sw/linux-2.4.9/include/net/checksum.h:31,
from /b2/sw/linux-2.4.9/include/linux/raid/md.h:34,
from init/main.c:24:
/b2/sw/linux-2.4.9/include/linux/netdevice.h: In function
`__netif_schedule':
/b2/sw/linux-2.4.9/include/linux/netdevice.h:489: warning: implicit
declaration of function `cpu_raise_softirq'
In file included from /b2/sw/linux-2.4.9/include/net/ip.h:39,
from /b2/sw/linux-2.4.9/include/net/checksum.h:31,
from /b2/sw/linux-2.4.9/include/linux/raid/md.h:34,
from init/main.c:24:
/b2/sw/linux-2.4.9/include/net/sock.h: In function `sock_rcvlowat':
/b2/sw/linux-2.4.9/include/net/sock.h:1248: warning: implicit
declaration of function `min'
/b2/sw/linux-2.4.9/include/net/sock.h:1248: parse error before `int'
/b2/sw/linux-2.4.9/include/net/sock.h:1249: warning: control reaches
end of non-void function
/b2/sw/linux-2.4.9/include/net/sock.h: In function `sock_intr_errno':
/b2/sw/linux-2.4.9/include/net/sock.h:1256: `LONG_MAX' undeclared
(first use in this function)
/b2/sw/linux-2.4.9/include/net/sock.h:1256: (Each undeclared
identifier is reported only once
/b2/sw/linux-2.4.9/include/net/sock.h:1256: for each function it
appears in.)
/b2/sw/linux-2.4.9/include/net/sock.h:1257: warning: control reaches
end of non-void function
In file included from /b2/sw/linux-2.4.9/include/linux/raid/md.h:39,
from init/main.c:24:
/b2/sw/linux-2.4.9/include/linux/completion.h: At top level:
/b2/sw/linux-2.4.9/include/linux/completion.h:30: parse error before
`('
/b2/sw/linux-2.4.9/include/linux/completion.h:31: parse error before
`('
In file included from /b2/sw/linux-2.4.9/include/linux/raid/md.h:51,
from init/main.c:24:
/b2/sw/linux-2.4.9/include/linux/raid/md_k.h: In function
`pers_to_level':
/b2/sw/linux-2.4.9/include/linux/raid/md_k.h:38: warning: implicit
declaration of function `panic'
In file included from init/main.c:33:
/b2/sw/linux-2.4.9/include/asm/bugs.h: In function `check_fpu':
/b2/sw/linux-2.4.9/include/asm/bugs.h:71: `KERN_EMERG' undeclared
(first use in this function)
/b2/sw/linux-2.4.9/include/asm/bugs.h:71: parse error before string
constant
/b2/sw/linux-2.4.9/include/asm/bugs.h:72: parse error before string
constant
/b2/sw/linux-2.4.9/include/asm/bugs.h:87: `KERN_INFO' undeclared
(first use in this function)
/b2/sw/linux-2.4.9/include/asm/bugs.h:87: parse error before string
constant
/b2/sw/linux-2.4.9/include/asm/bugs.h:92: parse error before string
constant
/b2/sw/linux-2.4.9/include/asm/bugs.h: In function `check_hlt':
/b2/sw/linux-2.4.9/include/asm/bugs.h:115: `KERN_INFO' undeclared
(first use in this function)
/b2/sw/linux-2.4.9/include/asm/bugs.h:115: parse error before string
constant
init/main.c: In function `profile_setup':
init/main.c:138: warning: implicit declaration of function
`get_option'
init/main.c: In function `name_to_kdev_t':
init/main.c:285: warning: implicit declaration of function
`simple_strtoul'
init/main.c: In function `debug_kernel':
init/main.c:393: `console_loglevel' undeclared (first use in this
function)
init/main.c: In function `quiet_kernel':
init/main.c:401: `console_loglevel' undeclared (first use in this
function)
make: *** [init/main.o] Error 1
[root@bits linux]#



Fred


_________________________________
On Saturday 18 August 2001 01:18 pm, Tony Hoyle wrote:
> Magnus Naeslund(f) wrote:
>
> > Isn't it more safe to do it like this:
> >
> > make mrproper
> > cp ../linux-2.4.8/.config .
> > make oldconfig
> > make xconfig
> > make bzImage && make modules && make modules_install && make
install
> >
> > ?
> > I thought this was the proper way to do it, no?
> >
> You don't need to make bzimage first, and you missed the dep/clean
steps
> (theoretically not needed any more but I've had some really strange
> compiler errors by missing them out).
>
> cp ../linux-2.4.8/.config .
> make oldconfig
> make xconfig
> make dep clean install modules modules_install
>
> Tony
>
> -
#ifndef __ASM_SYSTEM_H
#define __ASM_SYSTEM_H

#include <linux/config.h>
#include <linux/kernel.h>
#include <asm/segment.h>
#include <linux/bitops.h> /* for LOCK_PREFIX */

#ifdef __KERNEL__

struct task_struct; /* one of the stranger aspects of C forward declarations.. */
extern void FASTCALL(__switch_to(struct task_struct *prev, struct task_struct *next));

#define prepare_to_switch() do { } while(0)
#define switch_to(prev,next,last) do { \
asm volatile("pushl %%esi\n\t" \
"pushl %%edi\n\t" \
"pushl %%ebp\n\t" \
"movl %%esp,%0\n\t" /* save ESP */ \
"movl %3,%%esp\n\t" /* restore ESP */ \
"movl $1f,%1\n\t" /* save EIP */ \
"pushl %4\n\t" /* restore EIP */ \
"jmp __switch_to\n" \
"1:\t" \
"popl %%ebp\n\t" \
"popl %%edi\n\t" \
"popl %%esi\n\t" \
:"=m" (prev->thread.esp),"=m" (prev->thread.eip), \
"=b" (last) \
:"m" (next->thread.esp),"m" (next->thread.eip), \
"a" (prev), "d" (next), \
"b" (prev)); \
} while (0)

#define _set_base(addr,base) do { unsigned long __pr; \
__asm__ __volatile__ ("movw %%dx,%1\n\t" \
"rorl $16,%%edx\n\t" \
"movb %%dl,%2\n\t" \
"movb %%dh,%3" \
:"=&d" (__pr) \
:"m" (*((addr)+2)), \
"m" (*((addr)+4)), \
"m" (*((addr)+7)), \
"0" (base) \
); } while(0)

#define _set_limit(addr,limit) do { unsigned long __lr; \
__asm__ __volatile__ ("movw %%dx,%1\n\t" \
"rorl $16,%%edx\n\t" \
"movb %2,%%dh\n\t" \
"andb $0xf0,%%dh\n\t" \
"orb %%dh,%%dl\n\t" \
"movb %%dl,%2" \
:"=&d" (__lr) \
:"m" (*(addr)), \
"m" (*((addr)+6)), \
"0" (limit) \
); } while(0)

#define set_base(ldt,base) _set_base( ((char *)&(ldt)) , (base) )
#define set_limit(ldt,limit) _set_limit( ((char *)&(ldt)) , ((limit)-1)>>12 )

static inline unsigned long _get_base(char * addr)
{
unsigned long __base;
__asm__("movb %3,%%dh\n\t"
"movb %2,%%dl\n\t"
"shll $16,%%edx\n\t"
"movw %1,%%dx"
:"=&d" (__base)
:"m" (*((addr)+2)),
"m" (*((addr)+4)),
"m" (*((addr)+7)));
return __base;
}

#define get_base(ldt) _get_base( ((char *)&(ldt)) )

/*
* Load a segment. Fall back on loading the zero
* segment if something goes wrong..
*/
#define loadsegment(seg,value) \
asm volatile("\n" \
"1:\t" \
"movl %0,%%" #seg "\n" \
"2:\n" \
".section .fixup,\"ax\"\n" \
"3:\t" \
"pushl $0\n\t" \
"popl %%" #seg "\n\t" \
"jmp 2b\n" \
".previous\n" \
".section __ex_table,\"a\"\n\t" \
".align 4\n\t" \
".long 1b,3b\n" \
".previous" \
: :"m" (*(unsigned int *)&(value)))

/*
* Clear and set 'TS' bit respectively
*/
#define clts() __asm__ __volatile__ ("clts")
#define read_cr0() ({ \
unsigned int __dummy; \
__asm__( \
"movl %%cr0,%0\n\t" \
:"=r" (__dummy)); \
__dummy; \
})
#define write_cr0(x) \
__asm__("movl %0,%%cr0": :"r" (x));
#define stts() write_cr0(8 | read_cr0())

#endif /* __KERNEL__ */

static inline unsigned long get_limit(unsigned long segment)
{
unsigned long __limit;
__asm__("lsll %1,%0"
:"=r" (__limit):"r" (segment));
return __limit+1;
}

#define nop() __asm__ __volatile__ ("nop")

#define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr))))

#define tas(ptr) (xchg((ptr),1))

struct __xchg_dummy { unsigned long a[100]; };
#define __xg(x) ((struct __xchg_dummy *)(x))


/*
* The semantics of XCHGCMP8B are a bit strange, this is why
* there is a loop and the loading of %%eax and %%edx has to
* be inside. This inlines well in most cases, the cached
* cost is around ~38 cycles. (in the future we might want
* to do an SIMD/3DNOW!/MMX/FPU 64-bit store here, but that
* might have an implicit FPU-save as a cost, so it's not
* clear which path to go.)
*/
static inline void __set_64bit (unsigned long long * ptr,
unsigned int low, unsigned int high)
{
__asm__ __volatile__ (
"\n1:\t"
"movl (%0), %%eax\n\t"
"movl 4(%0), %%edx\n\t"
"cmpxchg8b (%0)\n\t"
"jnz 1b"
: /* no outputs */
: "D"(ptr),
"b"(low),
"c"(high)
: "ax","dx","memory");
}

static inline void __set_64bit_constant (unsigned long long *ptr,
unsigned long long value)
{
__set_64bit(ptr,(unsigned int)(value), (unsigned int)((value)>>32ULL));
}
#define ll_low(x) *(((unsigned int*)&(x))+0)
#define ll_high(x) *(((unsigned int*)&(x))+1)

static inline void __set_64bit_var (unsigned long long *ptr,
unsigned long long value)
{
__set_64bit(ptr,ll_low(value), ll_high(value));
}

#define set_64bit(ptr,value) \
(__builtin_constant_p(value) ? \
__set_64bit_constant(ptr, value) : \
__set_64bit_var(ptr, value) )

#define _set_64bit(ptr,value) \
(__builtin_constant_p(value) ? \
__set_64bit(ptr, (unsigned int)(value), (unsigned int)((value)>>32ULL) ) : \
__set_64bit(ptr, ll_low(value), ll_high(value)) )

/*
* Note: no "lock" prefix even on SMP: xchg always implies lock anyway
* Note 2: xchg has side effect, so that attribute volatile is necessary,
* but generally the primitive is invalid, *ptr is output argument. --ANK
*/
static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
{
switch (size) {
case 1:
__asm__ __volatile__("xchgb %b0,%1"
:"=q" (x)
:"m" (*__xg(ptr)), "0" (x)
:"memory");
break;
case 2:
__asm__ __volatile__("xchgw %w0,%1"
:"=r" (x)
:"m" (*__xg(ptr)), "0" (x)
:"memory");
break;
case 4:
__asm__ __volatile__("xchgl %0,%1"
:"=r" (x)
:"m" (*__xg(ptr)), "0" (x)
:"memory");
break;
}
return x;
}

/*
* Atomic compare and exchange. Compare OLD with MEM, if identical,
* store NEW in MEM. Return the initial value in MEM. Success is
* indicated by comparing RETURN with OLD.
*/

#ifdef CONFIG_X86_CMPXCHG
#define __HAVE_ARCH_CMPXCHG 1

static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
unsigned long new, int size)
{
unsigned long prev;
switch (size) {
case 1:
__asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
: "=a"(prev)
: "q"(new), "m"(*__xg(ptr)), "0"(old)
: "memory");
return prev;
case 2:
__asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
: "=a"(prev)
: "q"(new), "m"(*__xg(ptr)), "0"(old)
: "memory");
return prev;
case 4:
__asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
: "=a"(prev)
: "q"(new), "m"(*__xg(ptr)), "0"(old)
: "memory");
return prev;
}
return old;
}

#define cmpxchg(ptr,o,n)\
((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\
(unsigned long)(n),sizeof(*(ptr))))

#else
/* Compiling for a 386 proper. Is it worth implementing via cli/sti? */
#endif

/*
* Force strict CPU ordering.
* And yes, this is required on UP too when we're talking
* to devices.
*
* For now, "wmb()" doesn't actually do anything, as all
* Intel CPU's follow what Intel calls a *Processor Order*,
* in which all writes are seen in the program order even
* outside the CPU.
*
* I expect future Intel CPU's to have a weaker ordering,
* but I'd also expect them to finally get their act together
* and add some real memory barriers if so.
*/
#define mb() __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")
#define rmb() mb()
#define wmb() __asm__ __volatile__ ("": : :"memory")

#ifdef CONFIG_SMP
#define smp_mb() mb()
#define smp_rmb() rmb()
#define smp_wmb() wmb()
#else
#define smp_mb() barrier()
#define smp_rmb() barrier()
#define smp_wmb() barrier()
#endif

#define set_mb(var, value) do { xchg(&var, value); } while (0)
#define set_wmb(var, value) do { var = value; wmb(); } while (0)

/* interrupt control.. */
#define __save_flags(x) __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */)
#define __restore_flags(x) __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory", "cc")
#define __cli() __asm__ __volatile__("cli": : :"memory")
#define __sti() __asm__ __volatile__("sti": : :"memory")
/* used in the idle loop; sti takes one instruction cycle to complete */
#define safe_halt() __asm__ __volatile__("sti; hlt": : :"memory")

/* For spinlocks etc */
#define local_irq_save(x) __asm__ __volatile__("pushfl ; popl %0 ; cli":"=g" (x): /* no input */ :"memory")
#define local_irq_restore(x) __restore_flags(x)
#define local_irq_disable() __cli()
#define local_irq_enable() __sti()

#ifdef CONFIG_SMP

extern void __global_cli(void);
extern void __global_sti(void);
extern unsigned long __global_save_flags(void);
extern void __global_restore_flags(unsigned long);
#define cli() __global_cli()
#define sti() __global_sti()
#define save_flags(x) ((x)=__global_save_flags())
#define restore_flags(x) __global_restore_flags(x)

#else

#define cli() __cli()
#define sti() __sti()
#define save_flags(x) __save_flags(x)
#define restore_flags(x) __restore_flags(x)

#endif

/*
* disable hlt during certain critical i/o operations
*/
#define HAVE_DISABLE_HLT
void disable_hlt(void);
void enable_hlt(void);

#endif
/* rwsem.h: R/W semaphores implemented using XADD/CMPXCHG for i486+
*
* Written by David Howells (dhowells@redhat.com).
*
* Derived from asm-i386/semaphore.h
*
*
* The MSW of the count is the negated number of active writers and waiting
* lockers, and the LSW is the total number of active locks
*
* The lock count is initialized to 0 (no active and no waiting lockers).
*
* When a writer subtracts WRITE_BIAS, it'll get 0xffff0001 for the case of an
* uncontended lock. This can be determined because XADD returns the old value.
* Readers increment by 1 and see a positive value when uncontended, negative
* if there are writers (and maybe) readers waiting (in which case it goes to
* sleep).
*
* The value of WAITING_BIAS supports up to 32766 waiting processes. This can
* be extended to 65534 by manually checking the whole MSW rather than relying
* on the S flag.
*
* The value of ACTIVE_BIAS supports up to 65535 active processes.
*
* This should be totally fair - if anything is waiting, a process that wants a
* lock will go to the back of the queue. When the currently active lock is
* released, if there's a writer at the front of the queue, then that and only
* that will be woken up; if there's a bunch of consequtive readers at the
* front, then they'll all be woken up, but no other readers will be.
*/

#ifndef _I386_RWSEM_H
#define _I386_RWSEM_H

#ifndef _LINUX_RWSEM_H
#error please dont include asm/rwsem.h directly, use linux/rwsem.h instead
#endif

#ifdef __KERNEL__

#include <linux/list.h>
#include <linux/spinlock.h>

struct rwsem_waiter;

extern struct rw_semaphore *FASTCALL(rwsem_down_read_failed(struct rw_semaphore *sem));
extern struct rw_semaphore *FASTCALL(rwsem_down_write_failed(struct rw_semaphore *sem));
extern struct rw_semaphore *FASTCALL(rwsem_wake(struct rw_semaphore *));

/*
* the semaphore definition
*/
struct rw_semaphore {
signed long count;
#define RWSEM_UNLOCKED_VALUE 0x00000000
#define RWSEM_ACTIVE_BIAS 0x00000001
#define RWSEM_ACTIVE_MASK 0x0000ffff
#define RWSEM_WAITING_BIAS (-0x00010000)
#define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS
#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS)
spinlock_t wait_lock;
struct list_head wait_list;
#if RWSEM_DEBUG
int debug;
#endif
};

/*
* initialisation
*/
#if RWSEM_DEBUG
#define __RWSEM_DEBUG_INIT , 0
#else
#define __RWSEM_DEBUG_INIT /* */
#endif

#define __RWSEM_INITIALIZER(name) \
{ RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, LIST_HEAD_INIT((name).wait_list) \
__RWSEM_DEBUG_INIT }

#define DECLARE_RWSEM(name) \
struct rw_semaphore name = __RWSEM_INITIALIZER(name)

static inline void init_rwsem(struct rw_semaphore *sem)
{
sem->count = RWSEM_UNLOCKED_VALUE;
spin_lock_init(&sem->wait_lock);
INIT_LIST_HEAD(&sem->wait_list);
#if RWSEM_DEBUG
sem->debug = 0;
#endif
}

/*
* lock for reading
*/
static inline void __down_read(struct rw_semaphore *sem)
{
__asm__ __volatile__(
"# beginning down_read\n\t"
LOCK_PREFIX " incl (%%eax)\n\t" /* adds 0x00000001, returns the old value */
" js 2f\n\t" /* jump if we weren't granted the lock */
"1:\n\t"
".section .text.lock,\"ax\"\n"
"2:\n\t"
" pushl %%ecx\n\t"
" pushl %%edx\n\t"
" call rwsem_down_read_failed\n\t"
" popl %%edx\n\t"
" popl %%ecx\n\t"
" jmp 1b\n"
".previous"
"# ending down_read\n\t"
: "+m"(sem->count)
: "a"(sem)
: "memory", "cc");
}

/*
* lock for writing
*/
static inline void __down_write(struct rw_semaphore *sem)
{
int tmp;

tmp = RWSEM_ACTIVE_WRITE_BIAS;
__asm__ __volatile__(
"# beginning down_write\n\t"
LOCK_PREFIX " xadd %0,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */
" testl %0,%0\n\t" /* was the count 0 before? */
" jnz 2f\n\t" /* jump if we weren't granted the lock */
"1:\n\t"
".section .text.lock,\"ax\"\n"
"2:\n\t"
" pushl %%ecx\n\t"
" call rwsem_down_write_failed\n\t"
" popl %%ecx\n\t"
" jmp 1b\n"
".previous\n"
"# ending down_write"
: "+d"(tmp), "+m"(sem->count)
: "a"(sem)
: "memory", "cc");
}

/*
* unlock after reading
*/
static inline void __up_read(struct rw_semaphore *sem)
{
__s32 tmp = -RWSEM_ACTIVE_READ_BIAS;
__asm__ __volatile__(
"# beginning __up_read\n\t"
LOCK_PREFIX " xadd %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */
" js 2f\n\t" /* jump if the lock is being waited upon */
"1:\n\t"
".section .text.lock,\"ax\"\n"
"2:\n\t"
" decw %%dx\n\t" /* do nothing if still outstanding active readers */
" jnz 1b\n\t"
" pushl %%ecx\n\t"
" call rwsem_wake\n\t"
" popl %%ecx\n\t"
" jmp 1b\n"
".previous\n"
"# ending __up_read\n"
: "+m"(sem->count), "+d"(tmp)
: "a"(sem)
: "memory", "cc");
}

/*
* unlock after writing
*/
static inline void __up_write(struct rw_semaphore *sem)
{
__asm__ __volatile__(
"# beginning __up_write\n\t"
" movl %2,%%edx\n\t"
LOCK_PREFIX " xaddl %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */
" jnz 2f\n\t" /* jump if the lock is being waited upon */
"1:\n\t"
".section .text.lock,\"ax\"\n"
"2:\n\t"
" decw %%dx\n\t" /* did the active count reduce to 0? */
" jnz 1b\n\t" /* jump back if not */
" pushl %%ecx\n\t"
" call rwsem_wake\n\t"
" popl %%ecx\n\t"
" jmp 1b\n"
".previous\n"
"# ending __up_write\n"
: "+m"(sem->count)
: "a"(sem), "i"(-RWSEM_ACTIVE_WRITE_BIAS)
: "memory", "cc", "edx");
}

/*
* implement atomic add functionality
*/
static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem)
{
__asm__ __volatile__(
LOCK_PREFIX "addl %1,%0"
:"=m"(sem->count)
:"ir"(delta), "m"(sem->count));
}

/*
* implement exchange and add functionality
*/
static inline int rwsem_atomic_update(int delta, struct rw_semaphore *sem)
{
int tmp = delta;

__asm__ __volatile__(
LOCK_PREFIX "xadd %0,(%2)"
: "+r"(tmp), "=m"(sem->count)
: "r"(sem), "m"(sem->count)
: "memory");

return tmp+delta;
}

#endif /* __KERNEL__ */
#endif /* _I386_RWSEM_H */
\
 
 \ /
  Last update: 2005-03-22 12:57    [W:0.224 / U:0.444 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site