- 论坛徽章:
- 0
|
我用到了down up
但是编译以后总是提示:
/tmp/ccC0koWl.o(.text+0x25): In function `.text.lock.KBUILD_BASENAME':
: undefined reference to `__down_failed'
/tmp/ccC0koWl.o(.text+0x2c): In function `.text.lock.KBUILD_BASENAME':
: undefined reference to `__up_wakeup'
collect2: ld returned 1 exit status
我的源代码:
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
#include <linux/config.h>;
#include <linux/mm.h>;
#include <linux/shm.h>;
#include <linux/init.h>;
#include <linux/msg.h>;
#include <linux/smp_lock.h>;
#include <linux/vmalloc.h>;
#include <linux/slab.h>;
#include <linux/highuid.h>;
#include <linux/wait.h>;
#include <asm/system.h>;
#include <asm/atomic.h>;
#include <asm/semaphore.h>;
#include <linux/kernel.h>;
#include <linux/sched.h>;
#include <linux/spinlock.h>;
struct ipc_ids {
int size;
int in_use;
int max_id;
unsigned short seq;
unsigned short seq_max;
struct semaphore sem;
spinlock_t ary;
struct ipc_id* entries;
};
static struct ipc_ids shm_ids;
asmlinkage long sys_shmget (key_t key, size_t size, int shmflg)
{
struct shmid_kernel *shp;
int err, id = 0;
down(&shm_ids.sem);
if (key == IPC_PRIVATE) {
//err = newseg(key, shmflg, size);
}
up(&shm_ids.sem);
return err;
}
int main()
{
return 0;
}
我的makefile:
#INCLUDE=-I/usr/src/linux/
#LIB=-L/data/oracle/product/9.2.0/lib/
#LINK=-ldl -lm -lpthread -lnsl -lirc
KERNELDIR =/usr/src/linux
include $(KERNELDIR)/.config
MODVERFILE = $(KERNELDIR)/include/linux/modversions.h
MODDEFS = -D__KERNEL__ -DMODULE -DMODVERSIONS
CFLAGS = -Wall -O2 -I$(KERNELDIR)/include -include $(MODVERFILE) -Wstrict-prototypes -fomit-frame-pointer -pipe -malign-loops=2 -malign-jumps=2 -malign-functions=2
SOURCE=$(wildcard *.c)
#SOURCE=main.c
CC=gcc
all:
$(CC) -w $(CFLAGS) $(MODDEFS) -o a.out $(SOURCE)
郁闷了我好多天 那位兄弟帮帮忙啊 |
|