📄 memalign.c
字号:
/* $Header: /home/harrison/c/tcgmsg/ipcv4.0/RCS/memalign.c,v 1.1 91/12/06 17:26:45 harrison Exp Locker: harrison $ */#if !defined(SUN) && !defined(CRAY)#if defined(ULTRIX) || defined(SGI) || defined(NEXT) || defined(HPUX)extern void *malloc();#else#ifndef IPSCextern char *malloc();#endif#endifchar *memalign(alignment, size) unsigned alignment; unsigned size;/* Cut from SUN man-page memalign() allocates size bytes on a specified alignment boundary, and returns a pointer to the allocated block. The value of the returned address is guaranteed to be an even multiple of alignment. Note: the value of alignment must be a power of two, and must be greater than or equal to the size of a word. No checking is done on the value of alignment ... should really.*/{ union screwup { unsigned long integer; char *address; } fiddle; unsigned long offset; alignment += alignment; /* Actually align on twice requested boundary */ fiddle.address = malloc((unsigned) (alignment+size)); if (fiddle.address != (char *) 0) { offset = fiddle.integer & (alignment-1); if (offset != 0) fiddle.address += alignment - offset; } return fiddle.address;}#endif#if defined(SUN)/* Use the system routine */void AvoidNullSymbolTable(){}#endif#if defined(CRAY)/* Alignment is not really an issue on the cray except when casting a character pointer to another type when information may be lost */extern char *malloc();char *memalign(alignment, size) unsigned alignment; unsigned size;{ return malloc(size);}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -