mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- The data structure alignment (file I/O buffer) is now configurable
at compile time. The default used to be 16 bytes, which is appropriate for the 68040/68060 but not for the PowerPC, which uses 32 or 128 bytes per cache line. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14787 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@ -27,6 +27,11 @@
|
||||
handler, the localized "*** BREAK" string will be printed rather
|
||||
than the built-in one.
|
||||
|
||||
- The data structure alignment (file I/O buffer) is now configurable
|
||||
at compile time. The default used to be 16 bytes, which is appropriate
|
||||
for the 68040/68060 but not for the PowerPC, which uses 32 or 128
|
||||
bytes per cache line.
|
||||
|
||||
|
||||
c.lib 1.184 (28.11.2004)
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: dirent_readdir.c,v 1.2 2004-08-07 09:15:32 obarthel Exp $
|
||||
* $Id: dirent_readdir.c,v 1.3 2004-12-26 13:14:47 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -87,16 +87,17 @@ readdir(DIR * directory_pointer)
|
||||
else
|
||||
{
|
||||
D_S(struct FileInfoBlock,fib);
|
||||
D_S(struct bcpl_name,bcpl_name);
|
||||
UBYTE * name = bcpl_name->name;
|
||||
struct MsgPort * port;
|
||||
UBYTE * bcpl_name;
|
||||
BPTR dir_lock;
|
||||
UBYTE name[8];
|
||||
|
||||
assert( (((ULONG)name) & 3) == 0 );
|
||||
|
||||
if(dh->dh_VolumeNode == NULL && NOT IsListEmpty(&dh->dh_VolumeList))
|
||||
dh->dh_VolumeNode = dh->dh_VolumeList.lh_Head;
|
||||
|
||||
bcpl_name = (STRPTR)((((ULONG)&name[0]) + 3UL) & ~3UL);
|
||||
strcpy(bcpl_name,"\1:"); /* BSTR for ":" */
|
||||
strcpy(name,"\1:"); /* BSTR for ":" */
|
||||
|
||||
while(result == NULL && dh->dh_VolumeNode != NULL && dh->dh_VolumeNode->ln_Succ != NULL)
|
||||
{
|
||||
@ -105,7 +106,7 @@ readdir(DIR * directory_pointer)
|
||||
port = DeviceProc(dh->dh_VolumeNode->ln_Name);
|
||||
if(port != NULL)
|
||||
{
|
||||
dir_lock = DoPkt(port,ACTION_LOCATE_OBJECT,ZERO,MKBADDR(bcpl_name),SHARED_LOCK, 0,0);
|
||||
dir_lock = DoPkt(port,ACTION_LOCATE_OBJECT,ZERO,MKBADDR(name),SHARED_LOCK, 0,0);
|
||||
if(dir_lock != ZERO)
|
||||
{
|
||||
if(Examine(dir_lock,fib))
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_fdhookentry.c,v 1.2 2004-11-28 10:01:26 obarthel Exp $
|
||||
* $Id: stdio_fdhookentry.c,v 1.3 2004-12-26 13:14:47 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -1290,7 +1290,7 @@ grow_file_size(struct fd * fd,int num_bytes,int * error_ptr)
|
||||
/* Allocate a little more memory than required to allow for
|
||||
* the buffer to be aligned to a cache line boundary.
|
||||
*/
|
||||
buffer = malloc((size_t)buffer_size + 15);
|
||||
buffer = malloc((size_t)buffer_size + (CACHE_LINE_SIZE-1));
|
||||
if(buffer == NULL)
|
||||
{
|
||||
SHOWMSG("not enough memory for write buffer");
|
||||
@ -1300,7 +1300,7 @@ grow_file_size(struct fd * fd,int num_bytes,int * error_ptr)
|
||||
}
|
||||
|
||||
/* Align the buffer to a cache line boundary. */
|
||||
aligned_buffer = (unsigned char *)(((ULONG)(buffer + 15)) & ~15UL);
|
||||
aligned_buffer = (unsigned char *)(((ULONG)(buffer + (CACHE_LINE_SIZE-1))) & ~(CACHE_LINE_SIZE-1));
|
||||
|
||||
memset(aligned_buffer,0,(size_t)buffer_size);
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_filliobreadbuffer.c,v 1.1.1.1 2004-07-26 16:31:29 obarthel Exp $
|
||||
* $Id: stdio_filliobreadbuffer.c,v 1.2 2004-12-26 13:14:47 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -37,22 +37,6 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/*
|
||||
int
|
||||
__iob_read_buffer_is_empty(struct iob * file)
|
||||
{
|
||||
int result;
|
||||
|
||||
assert( file != NULL );
|
||||
|
||||
result = (file->iob_BufferReadBytes == 0 || file->iob_BufferPosition == file->iob_BufferReadBytes);
|
||||
|
||||
return(result);
|
||||
}
|
||||
*/
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
int
|
||||
__fill_iob_read_buffer(struct iob * file)
|
||||
{
|
||||
@ -73,9 +57,6 @@ __fill_iob_read_buffer(struct iob * file)
|
||||
if(__check_abort_enabled)
|
||||
__check_abort();
|
||||
|
||||
if(FLAG_IS_CLEAR(file->iob_Flags,IOBF_IN_USE)) /* ZZZ this does not really belong here; paranoia? */
|
||||
goto out;
|
||||
|
||||
/* Flush all line buffered streams before we proceed to fill this buffer. */
|
||||
if((file->iob_Flags & IOBF_BUFFER_MODE) == IOBF_BUFFER_MODE_LINE)
|
||||
{
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_headers.h,v 1.5 2004-11-28 10:01:26 obarthel Exp $
|
||||
* $Id: stdio_headers.h,v 1.6 2004-12-26 13:14:47 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -104,6 +104,14 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* CPU cache line size; used for alignment purposes with some data structures.
|
||||
This should be determined dynamically rather than preset here. For the
|
||||
68040/68060 the cache line size is 16 bytes, for the PowerPC G4 it's
|
||||
32 bytes and 128 bytes (gross!) for the PowerPC G5. */
|
||||
#define CACHE_LINE_SIZE 32UL
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* The directory entry type a socket is identified with (in a FileInfoBlock). */
|
||||
#define ST_SOCKET (31082002)
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_init_exit.c,v 1.3 2004-12-26 10:28:56 obarthel Exp $
|
||||
* $Id: stdio_init_exit.c,v 1.4 2004-12-26 13:14:47 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -176,12 +176,12 @@ __stdio_init(void)
|
||||
PROFILE_ON();
|
||||
|
||||
/* Allocate a little more memory than necessary. */
|
||||
buffer = malloc(BUFSIZ + 15);
|
||||
buffer = malloc(BUFSIZ + (CACHE_LINE_SIZE-1));
|
||||
if(buffer == NULL)
|
||||
goto out;
|
||||
|
||||
/* Align the buffer start address to a cache line boundary. */
|
||||
aligned_buffer = (char *)((ULONG)(buffer + 15) & ~15UL);
|
||||
aligned_buffer = (char *)((ULONG)(buffer + (CACHE_LINE_SIZE-1)) & ~(CACHE_LINE_SIZE-1));
|
||||
|
||||
__initialize_fd(__fd[i],(HOOKFUNC)__fd_hook_entry,default_file,fd_flags);
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_openiob.c,v 1.3 2004-11-03 15:39:04 obarthel Exp $
|
||||
* $Id: stdio_openiob.c,v 1.4 2004-12-26 13:14:47 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -130,7 +130,7 @@ __open_iob(const char *filename, const char *mode, int file_descriptor, int slot
|
||||
SHOWMSG("allocating file buffer");
|
||||
|
||||
/* Allocate a little more memory than necessary. */
|
||||
buffer = malloc(BUFSIZ + 15);
|
||||
buffer = malloc(BUFSIZ + (CACHE_LINE_SIZE-1));
|
||||
if(buffer == NULL)
|
||||
{
|
||||
SHOWMSG("that didn't work");
|
||||
@ -140,7 +140,7 @@ __open_iob(const char *filename, const char *mode, int file_descriptor, int slot
|
||||
}
|
||||
|
||||
/* Align the buffer start address to a cache line boundary. */
|
||||
aligned_buffer = (char *)((ULONG)(buffer + 15) & ~15UL);
|
||||
aligned_buffer = (char *)((ULONG)(buffer + (CACHE_LINE_SIZE-1)) & ~(CACHE_LINE_SIZE-1));
|
||||
|
||||
if(file_descriptor < 0)
|
||||
{
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_setvbuf.c,v 1.1.1.1 2004-07-26 16:31:41 obarthel Exp $
|
||||
* $Id: stdio_setvbuf.c,v 1.2 2004-12-26 13:14:47 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -120,7 +120,7 @@ setvbuf(FILE *stream,char *buf,int bufmode,size_t size)
|
||||
if(size > 0 && buf == NULL)
|
||||
{
|
||||
/* Allocate a little more memory than necessary. */
|
||||
new_buffer = malloc(size + 15);
|
||||
new_buffer = malloc(size + (CACHE_LINE_SIZE-1));
|
||||
if(new_buffer == NULL)
|
||||
{
|
||||
errno = ENOBUFS;
|
||||
@ -167,7 +167,7 @@ setvbuf(FILE *stream,char *buf,int bufmode,size_t size)
|
||||
file->iob_CustomBuffer = new_buffer;
|
||||
|
||||
/* Align the buffer start address to a cache line boundary. */
|
||||
new_buffer = (char *)((ULONG)(new_buffer + 15) & ~15UL);
|
||||
new_buffer = (char *)((ULONG)(new_buffer + (CACHE_LINE_SIZE-1)) & ~(CACHE_LINE_SIZE-1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user