?? rtai_shm.h
字號:
/*COPYRIGHT (C) 1999 Paolo Mantegazza (mantegazza@aero.polimi.it)This library is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 2 of the License, or (at your option) any later version.This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.*/#define REAL_SIZE(x) (((x) - 1) & PAGE_MASK) + PAGE_SIZEextern void *rtai_kmalloc_f(int name, int size, unsigned long pid);#define rtai_kmalloc(x, y) rtai_kmalloc_f((x), (y), (unsigned long)(&(__this_module)));extern void rtai_kfree_f(int name, unsigned long pid);#define rtai_kfree(x) rtai_kfree_f((x), (unsigned long)(&(__this_module)));static inline unsigned long nam2num(const char *name){ int i = 0; union { struct { long num; char eos; } num; char name[5]; } retval; if (!name[0]) { return 0x454e4f4e; // "NULL" } retval.num.eos = 0; while (i < 4 && (retval.name[i] = name[i])) { i++; } return retval.num.num;}static inline void num2nam(unsigned long num, char *name){ int i = 0; union { struct { long num; char eos; } num; char name[5]; } retval; retval.num.num = num; retval.num.eos = 0; while (i < 4 && (name[i] = retval.name[i])) { i++; }}#ifndef MODULE#include <asm/page.h>static void *rtai_malloc(unsigned long name, int size){ void *adr; int hook; struct { unsigned long name, size; } arg; if (size <= 0) { return 0; } if ((hook = open("/dev/rtai_shm", O_RDWR)) < 0) { return 0; } arg.name = name; arg.size = size; if (!(size = ioctl(hook, 1, (unsigned long)(&arg)))) { return 0; } adr = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_SHARED|MAP_FILE, hook, 0); close(hook); return adr;}static inline void rtai_free(int name, void *adr){ int size, hook; if ((size = ioctl(hook = open("/dev/rtai_shm", O_RDWR), 2, name))) { munmap(adr, size); ioctl(hook, 3, name); } close(hook);}#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -