🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Karl Berry Wed, 09 Sep 1992 15:40
ld errors on decstation
#1107
Author: Karl Berry
Date: Wed, 09 Sep 1992 15:40
3032 lines
32706 bytes
GCC 2.2.2 on a DECstation 3100 running Ultrix 4.2a, configured as `decstation'.

I get strange errors from ld after compiling the following file with -g -O.  
If I remove the -O, the problem goes away, and I just get the (expected)
message that main is undefined.

gcc -g -O -v temp.c
Reading specs from /usr/local/gnu/lib/gcc-lib/decstation/2.2.2/specs
gcc version 2.2.2
 /usr/local/gnu/lib/gcc-lib/decstation/2.2.2/cpp -lang-c -v -undef -D__GNUC__=2 -D__ANSI_COMPAT -DMIPSEL -DR3000 -DSYSTYPE_BSD -D_SYSTYPE_BSD -Dbsd4_2 -Dhost_mips -Dmips -Dultrix -Dunix -D__ANSI_COMPAT -D__MIPSEL__ -D__R3000__ -D__SYSTYPE_BSD__ -D___SYSTYPE_BSD__ -D__bsd4_2__ -D__host_mips__ -D__mips__ -D__ultrix__ -D__unix__ -D__ANSI_COMPAT -D__MIPSEL -D__R3000 -D__SYSTYPE_BSD -D___SYSTYPE_BSD -D__bsd4_2 -D__host_mips -D__mips -D__ultrix -D__unix -D__OPTIMIZE__ -g -D__LANGUAGE_C__ -D__LANGUAGE_C -DLANGUAG
E_C temp.c /tmp/cca09238.i
GNU CPP version 2.2.2 [AL 1.1, MM 19] DECstation running ultrix
 /usr/local/gnu/lib/gcc-lib/decstation/2.2.2/cc1 /tmp/cca09238.i -mgpopt -quiet -dumpbase temp.c -g -O -version -o /tmp/cca09238.s
GNU C version 2.2.2 [AL 1.1, MM 19] DECstation running ultrix compiled by GNU C version 2.2.1.
 as -nocpp -EL -O2 -g -v -o temp.o /tmp/cca09238.s
/usr/lib/cmplrs/cc/as0 -v -G 8 -EL -g2 -O2 /tmp/cca09238.s -o /tmp/ctmaa09340 -t /tmp/ctmsta09340 
as0: malloc_user_error my_bzero my_bcopy gcd malloc_from_sys malloc_find_space malloc free calloc cfree malloc_usable_size realloc memalign valloc malloc_stats 
0.5u 0.1s 0:03 18% 74+126k 0+14io 8pf+0w
/usr/lib/cmplrs/cc/as1 -v -G 8 -p0 -EL -g2 -O2 /tmp/ctmaa09340 -o temp.o -t /tmp/ctmsta09340 
as1: malloc_user_error my_bzero my_bcopy gcd malloc_from_sys malloc_find_space malloc free calloc cfree malloc_usable_size realloc memalign valloc malloc_stats 
0.4u 0.3s 0:04 16% 131+200k 3+4io 7pf+0w
 /usr/local/gnu/lib/gcc-lib/decstation/2.2.2/mips-tfile -v -o temp.o /tmp/cca09238.s
mips-tfile version 2.2.2 [AL 1.1, MM 19] DECstation running ultrix
 /usr/local/gnu/lib/gcc-lib/decstation/2.2.2/ld -EL /usr/lib/cmplrs/cc/crt0.o -L/usr/local/gnu/lib/gcc-lib/decstation/2.2.2 -L/usr/lib/cmplrs/cc -L/usr/lib/cmplrs/cc -L/usr/local/gnu/lib temp.o -lgcc -lc -lgcc
ld:
Undefined:
main
__new_handler: both a large and small symbol (possible gp relocation errors may result)
temp.o: gp relocation out-of-range in .text section for relocation entry 9 for symbol: __new_handler
temp.o: above gp relocation entry for non .sdata or .sbss symbol
gp relocation out-of-range for small data or bss by,
              0 in the positive direction,
           2448 in the negative direction.
All data will fit into the global pointer area
Best -G num value to compile all -count'ed objects
creating a.out with is 1920 (or greater)
Best -G num value calculation reliable only if all
-count'ed objects were compiled with -G num greater or
equal to maximum size of a literal pool item (8).
collect: /usr/bin/ld returned 1 exit status

# 1 "malloc.c"
 




















 
 







 





























































 












































































































































 




# 1 "//usr/include/stdio.h" 1
 
 


























 



























































# 1 "/usr/include/ansi_compat.h" 1 3
 



 





















 

















# 116 "/usr/include/ansi_compat.h" 3

# 89 "//usr/include/stdio.h" 2



typedef unsigned int	size_t;		 









			 




extern	struct	_iobuf {
	int	_cnt;
	char	*_ptr;
	char	*_base;
	int	_bufsiz;
	short	_flag;
	short	_file;
} _iob[3 ];
typedef	struct _iobuf	FILE;

typedef	long	fpos_t;

















 







 



extern int 	getc( FILE *__stream );
extern int	getchar( void );
extern int	putc( int __c, FILE *__stream);
extern int	putchar( int __c);
extern int	feof( FILE *__stream );
extern int	ferror( FILE *__stream );
extern int	fileno( FILE *__stream );
extern int	_filbuf( FILE *p);
extern int	_flsbuf( unsigned char x , FILE *p);
















typedef char *va_list;

 



extern void	clearerr( FILE *__stream); 
extern int	fclose( FILE *__stream );
extern FILE *	fdopen( int __filedes, char *__type );
extern int	fflush( FILE *__stream );
extern int	fgetc( FILE *__stream );
extern int	fgetpos( FILE *__stream, fpos_t *__pos );
extern char *	fgets( char *__s, int __n, FILE *__stream );
extern FILE *	fopen( const char *__filename, const char *__type );
extern int	fprintf( FILE *__stream, const char *__format, ... );
extern int	fputc( int __c, FILE *__stream );
extern int	fputs( const char *__s, FILE *__stream );
extern size_t	fread( void *__ptr, size_t __size,
			size_t __nitems, FILE *__stream ); 
extern FILE *	freopen( const char *__filename, const char *__type,
			FILE *__stream );
extern int	fscanf( FILE *__stream, const char *__format, ... );
extern int	fseek( FILE *__stream, long __offset, int __ptrname );
extern int	fsetpos( FILE *__stream, const fpos_t *__pos );
extern long	ftell( FILE *__stream );
extern size_t	fwrite( const void *__ptr, size_t __size,
			size_t __nitems, FILE *__stream );
extern char *	gets( char *__s );	
extern void	perror( const char *__s );
extern FILE  *	popen(const char *__command, const char *__type );
extern int	printf( const char *__format, ... );	
extern int	puts( const char *__s );	
extern int	remove( const char *__filename );
extern int	rename( const char *__from, const char *__to );
extern void	rewind( FILE *__stream );
extern int	scanf( const char *__format, ... );	
extern void	setbuf( FILE *__stream, char *__buf );
extern int	setvbuf( FILE *__stream, char *__buf,
			int __type, size_t __size );
extern int	sscanf( const char *__s, const char *__format, ... );
extern FILE *	tmpfile( void );	
extern char *	tmpnam( char *__s );
extern int	ungetc( int __c, FILE *__stream );
extern int	vfprintf( FILE *__stream, const char *__format, va_list __ap );
extern int	vprintf( const char *__format, va_list __ap );
extern int	vsprintf( char *__s, const char *__format, va_list __ap);


extern char *	tempnam( const char *__dir, const char *__pfx);
extern int	putw( int __w, FILE *__stream );
extern int	getw(FILE *__stream);
extern int	pclose( FILE *__stream );


# 298 "//usr/include/stdio.h"



 
extern int	sprintf( char *__s, const char *__format, ... );



















# 239 "malloc.c" 2







# 1 "/usr/include/sys/types.h" 1 3
 

 



























 















































# 1 "/usr/include/ansi_compat.h" 1 3
 



 





















 

















# 116 "/usr/include/ansi_compat.h" 3

# 79 "/usr/include/sys/types.h" 2 3




 



 


 


 


typedef	unsigned char	u_char;
typedef	unsigned short	u_short;
typedef	unsigned int	u_int;
typedef	unsigned int	uint;		 
typedef	unsigned long	u_long;
typedef	unsigned short	ushort;		 

typedef	volatile char		v_char;
typedef	volatile short		v_short;
typedef	volatile long		v_long;
typedef	volatile unsigned char	vu_char;
typedef	volatile unsigned short	vu_short;
typedef	volatile unsigned long	vu_long;

typedef

	signed

		char	s_char;









typedef	struct	_physadr { int r[1]; } *physadr;
 



typedef	struct	label_t	{
	int	val[12];
} label_t;


typedef	struct	_quad { long val[2]; } quad;
typedef	long	daddr_t;
typedef	char *	caddr_t;
typedef u_long	gno_t;
typedef short	cnt_t;			 
typedef	long	swblk_t;
typedef long	paddr_t;		 
typedef	long	audit_ID_t;


typedef	short	dev_t;
typedef short	gid_t;			 
typedef	unsigned long	ino_t;
typedef unsigned short	mode_t;		 
typedef short	nlink_t;		 
typedef	int	off_t;


typedef int	pid_t;			 

typedef short	uid_t;			 


typedef int	time_t;









typedef int	clock_t;			 

typedef long	key_t;			 




 











 









 

typedef long	fd_mask;






typedef	struct fd_set {
	fd_mask	fds_bits[(((4096	 )+(( (sizeof(fd_mask) * 8		)	)-1))/( (sizeof(fd_mask) * 8		)	)) ];
} fd_set;








# 246 "malloc.c" 2

extern void*     sbrk(size_t      );



extern volatile void abort();









 





 


static volatile void malloc_user_error()



{
  fputs("malloc/free/realloc: clobbered space detected\n", (&_iob[2]) ); abort();
}


 





static void
my_bzero (mem, len)
    char *mem;
    unsigned len;
{
  int i;
  for (i = 0; i < len; i++)
    mem[i] = 0;
}

static void
my_bcopy (from, to, size)
     char *from, *to;
     int size;
{
  int i;
  for (i = 0; i < size; i++)
    to[i] = from[i];
}



 


struct malloc_chunk
{
  size_t               size;      
                                  

  struct malloc_chunk* fd;        
  struct malloc_chunk* bk;

};

typedef struct malloc_chunk* mchunkptr;

struct malloc_bin
{
  struct malloc_chunk hd;         
  size_t              dirty;      
                                  
                                  
                                  
};

typedef struct malloc_bin* mbinptr;


 









 

static inline size_t       request2size(size_t       request)
{
  return  (request == 0) ?  (sizeof(struct malloc_chunk) +                   (sizeof(size_t      )) )  : 
    ((request +       (                  (sizeof(size_t      ))  +                   (sizeof(size_t      )) )  +         (      (                  (sizeof(size_t      ))  +                   (sizeof(size_t      )) )  - 1) ) 
      & ~(        (      (                  (sizeof(size_t      ))  +                   (sizeof(size_t      )) )  - 1) ));
}


static inline int aligned_OK(void* m)  
{
  return ((size_t      )(m) & (        (      (                  (sizeof(size_t      ))  +                   (sizeof(size_t      )) )  - 1) )) == 0;
}


 




 





static struct malloc_bin  av[120   ] = 
{
  { { 0, &(av[0].hd),  &(av[0].hd) }, 0 },
  { { 0, &(av[1].hd),  &(av[1].hd) }, 0 },
  { { 0, &(av[2].hd),  &(av[2].hd) }, 0 },
  { { 0, &(av[3].hd),  &(av[3].hd) }, 0 },
  { { 0, &(av[4].hd),  &(av[4].hd) }, 0 },
  { { 0, &(av[5].hd),  &(av[5].hd) }, 0 },
  { { 0, &(av[6].hd),  &(av[6].hd) }, 0 },
  { { 0, &(av[7].hd),  &(av[7].hd) }, 0 },
  { { 0, &(av[8].hd),  &(av[8].hd) }, 0 },
  { { 0, &(av[9].hd),  &(av[9].hd) }, 0 },

  { { 0, &(av[10].hd), &(av[10].hd) }, 0 },
  { { 0, &(av[11].hd), &(av[11].hd) }, 0 },
  { { 0, &(av[12].hd), &(av[12].hd) }, 0 },
  { { 0, &(av[13].hd), &(av[13].hd) }, 0 },
  { { 0, &(av[14].hd), &(av[14].hd) }, 0 },
  { { 0, &(av[15].hd), &(av[15].hd) }, 0 },
  { { 0, &(av[16].hd), &(av[16].hd) }, 0 },
  { { 0, &(av[17].hd), &(av[17].hd) }, 0 },
  { { 0, &(av[18].hd), &(av[18].hd) }, 0 },
  { { 0, &(av[19].hd), &(av[19].hd) }, 0 },

  { { 0, &(av[20].hd), &(av[20].hd) }, 0 },
  { { 0, &(av[21].hd), &(av[21].hd) }, 0 },
  { { 0, &(av[22].hd), &(av[22].hd) }, 0 },
  { { 0, &(av[23].hd), &(av[23].hd) }, 0 },
  { { 0, &(av[24].hd), &(av[24].hd) }, 0 },
  { { 0, &(av[25].hd), &(av[25].hd) }, 0 },
  { { 0, &(av[26].hd), &(av[26].hd) }, 0 },
  { { 0, &(av[27].hd), &(av[27].hd) }, 0 },
  { { 0, &(av[28].hd), &(av[28].hd) }, 0 },
  { { 0, &(av[29].hd), &(av[29].hd) }, 0 },

  { { 0, &(av[30].hd), &(av[30].hd) }, 0 },
  { { 0, &(av[31].hd), &(av[31].hd) }, 0 },
  { { 0, &(av[32].hd), &(av[32].hd) }, 0 },
  { { 0, &(av[33].hd), &(av[33].hd) }, 0 },
  { { 0, &(av[34].hd), &(av[34].hd) }, 0 },
  { { 0, &(av[35].hd), &(av[35].hd) }, 0 },
  { { 0, &(av[36].hd), &(av[36].hd) }, 0 },
  { { 0, &(av[37].hd), &(av[37].hd) }, 0 },
  { { 0, &(av[38].hd), &(av[38].hd) }, 0 },
  { { 0, &(av[39].hd), &(av[39].hd) }, 0 },

  { { 0, &(av[40].hd), &(av[40].hd) }, 0 },
  { { 0, &(av[41].hd), &(av[41].hd) }, 0 },
  { { 0, &(av[42].hd), &(av[42].hd) }, 0 },
  { { 0, &(av[43].hd), &(av[43].hd) }, 0 },
  { { 0, &(av[44].hd), &(av[44].hd) }, 0 },
  { { 0, &(av[45].hd), &(av[45].hd) }, 0 },
  { { 0, &(av[46].hd), &(av[46].hd) }, 0 },
  { { 0, &(av[47].hd), &(av[47].hd) }, 0 },
  { { 0, &(av[48].hd), &(av[48].hd) }, 0 },
  { { 0, &(av[49].hd), &(av[49].hd) }, 0 },

  { { 0, &(av[50].hd), &(av[50].hd) }, 0 },
  { { 0, &(av[51].hd), &(av[51].hd) }, 0 },
  { { 0, &(av[52].hd), &(av[52].hd) }, 0 },
  { { 0, &(av[53].hd), &(av[53].hd) }, 0 },
  { { 0, &(av[54].hd), &(av[54].hd) }, 0 },
  { { 0, &(av[55].hd), &(av[55].hd) }, 0 },
  { { 0, &(av[56].hd), &(av[56].hd) }, 0 },
  { { 0, &(av[57].hd), &(av[57].hd) }, 0 },
  { { 0, &(av[58].hd), &(av[58].hd) }, 0 },
  { { 0, &(av[59].hd), &(av[59].hd) }, 0 },

  { { 0, &(av[60].hd), &(av[60].hd) }, 0 },
  { { 0, &(av[61].hd), &(av[61].hd) }, 0 },
  { { 0, &(av[62].hd), &(av[62].hd) }, 0 },
  { { 0, &(av[63].hd), &(av[63].hd) }, 0 },
  { { 0, &(av[64].hd), &(av[64].hd) }, 0 },
  { { 0, &(av[65].hd), &(av[65].hd) }, 0 },
  { { 0, &(av[66].hd), &(av[66].hd) }, 0 },
  { { 0, &(av[67].hd), &(av[67].hd) }, 0 },
  { { 0, &(av[68].hd), &(av[68].hd) }, 0 },
  { { 0, &(av[69].hd), &(av[69].hd) }, 0 },

  { { 0, &(av[70].hd), &(av[70].hd) }, 0 },
  { { 0, &(av[71].hd), &(av[71].hd) }, 0 },
  { { 0, &(av[72].hd), &(av[72].hd) }, 0 },
  { { 0, &(av[73].hd), &(av[73].hd) }, 0 },
  { { 0, &(av[74].hd), &(av[74].hd) }, 0 },
  { { 0, &(av[75].hd), &(av[75].hd) }, 0 },
  { { 0, &(av[76].hd), &(av[76].hd) }, 0 },
  { { 0, &(av[77].hd), &(av[77].hd) }, 0 },
  { { 0, &(av[78].hd), &(av[78].hd) }, 0 },
  { { 0, &(av[79].hd), &(av[79].hd) }, 0 },

  { { 0, &(av[80].hd), &(av[80].hd) }, 0 },
  { { 0, &(av[81].hd), &(av[81].hd) }, 0 },
  { { 0, &(av[82].hd), &(av[82].hd) }, 0 },
  { { 0, &(av[83].hd), &(av[83].hd) }, 0 },
  { { 0, &(av[84].hd), &(av[84].hd) }, 0 },
  { { 0, &(av[85].hd), &(av[85].hd) }, 0 },
  { { 0, &(av[86].hd), &(av[86].hd) }, 0 },
  { { 0, &(av[87].hd), &(av[87].hd) }, 0 },
  { { 0, &(av[88].hd), &(av[88].hd) }, 0 },
  { { 0, &(av[89].hd), &(av[89].hd) }, 0 },

  { { 0, &(av[90].hd), &(av[90].hd) }, 0 },
  { { 0, &(av[91].hd), &(av[91].hd) }, 0 },
  { { 0, &(av[92].hd), &(av[92].hd) }, 0 },
  { { 0, &(av[93].hd), &(av[93].hd) }, 0 },
  { { 0, &(av[94].hd), &(av[94].hd) }, 0 },
  { { 0, &(av[95].hd), &(av[95].hd) }, 0 },
  { { 0, &(av[96].hd), &(av[96].hd) }, 0 },
  { { 0, &(av[97].hd), &(av[97].hd) }, 0 },
  { { 0, &(av[98].hd), &(av[98].hd) }, 0 },
  { { 0, &(av[99].hd), &(av[99].hd) }, 0 },

  { { 0, &(av[100].hd), &(av[100].hd) }, 0 },
  { { 0, &(av[101].hd), &(av[101].hd) }, 0 },
  { { 0, &(av[102].hd), &(av[102].hd) }, 0 },
  { { 0, &(av[103].hd), &(av[103].hd) }, 0 },
  { { 0, &(av[104].hd), &(av[104].hd) }, 0 },
  { { 0, &(av[105].hd), &(av[105].hd) }, 0 },
  { { 0, &(av[106].hd), &(av[106].hd) }, 0 },
  { { 0, &(av[107].hd), &(av[107].hd) }, 0 },
  { { 0, &(av[108].hd), &(av[108].hd) }, 0 },
  { { 0, &(av[109].hd), &(av[109].hd) }, 0 },

  { { 0, &(av[110].hd), &(av[110].hd) }, 0 },
  { { 0, &(av[111].hd), &(av[111].hd) }, 0 },
  { { 0, &(av[112].hd), &(av[112].hd) }, 0 },
  { { 0, &(av[113].hd), &(av[113].hd) }, 0 },
  { { 0, &(av[114].hd), &(av[114].hd) }, 0 },
  { { 0, &(av[115].hd), &(av[115].hd) }, 0 },
  { { 0, &(av[116].hd), &(av[116].hd) }, 0 },
  { { 0, &(av[117].hd), &(av[117].hd) }, 0 },
  { { 0, &(av[118].hd), &(av[118].hd) }, 0 },
  { { 0, &(av[119].hd), &(av[119].hd) }, 0 }
};

 



static inline mbinptr size2bin(size_t       sz)
{
  mbinptr b = av;
  while (sz >= ((sizeof(struct malloc_chunk) +                   (sizeof(size_t      )) )  * 2)) { b += 4; sz >>= 1; }  
  b += (sz - (sizeof(struct malloc_chunk) +                   (sizeof(size_t      )) ) ) >> 2;                          
  return b;
}



 

# 561 "malloc.c"




 
 

static size_t       gcd(size_t       a, size_t       b)
{
  size_t       tmp;
  
  if (b > a)
  {
    tmp = a; a = b; b = tmp;
  }
  for(;;)
  {
    if (b == 0)
      return a;
    else if (b == 1)
      return b;
    else
    {
      tmp = b;
      b = a % b;
      a = tmp;
    }
  }
}

static inline size_t       lcm(size_t       x, size_t       y)
{
  return x / gcd(x, y) * y;
}



 






  
 


 



 



 


static inline void set_size(mchunkptr p, size_t       sz)
{
  p->size = *((int*)((char*)(p) + sz -                   (sizeof(size_t      )) )) = sz;
}




 

static inline void* chunk2mem(mchunkptr p) 
{ 
    ((p)->size |=  0x1 ) ;
  return (void*)((char*)(p) +                   (sizeof(size_t      )) ); 
}

static inline mchunkptr mem2chunk(void* mem) 
{ 
  mchunkptr p = (mchunkptr)((char*)(mem) -                   (sizeof(size_t      )) ); 

   
  size_t       sz = p->size & ~( 0x1 );
  if (p->size == sz || sz != *((int*)((char*)(p) + sz -                   (sizeof(size_t      )) )))
    malloc_user_error();

  p->size = sz;    
  return p;
}



 


 

static mbinptr malloc_maxbin = (&(av[0])) ;


 


 

static inline void unlink(mchunkptr p)
{
  mchunkptr b = p->bk;
  mchunkptr f = p->fd;

  f->bk = b;  b->fd = f;

   ;
}



 

static inline void split(mchunkptr p, size_t       offset)
{
  size_t       room = p->size - offset;
  if (room >= (sizeof(struct malloc_chunk) +                   (sizeof(size_t      )) ) )
  {
    mbinptr   bn = size2bin(room);                   
    mchunkptr h  = &(bn->hd);                        
    mchunkptr b  = h->bk;                            
    mchunkptr t = (mchunkptr)((char*)(p) + offset);  
    
     
    t->size = *((int*)((char*)(t) + room    -                   (sizeof(size_t      )) )) = room;

     
    t->bk = b;  t->fd = h;  h->bk = b->fd = t;
    
     
    if (h == b && bn > malloc_maxbin) malloc_maxbin = bn; 

     
    p->size = *((int*)((char*)(p) + offset  -                   (sizeof(size_t      )) )) = offset;

     ;
  }
}



 
 

static inline void consollink(mchunkptr p)
{
  mbinptr   bn = size2bin(p->size);
  mchunkptr h  = &(bn->hd);
  mchunkptr b  = h->bk;

  p->bk = b;  p->fd = h;  h->bk = b->fd = p;

  if (h == b && bn > malloc_maxbin) malloc_maxbin = bn; 

   ;
}


 

static inline void frontlink(mchunkptr p)
{
  mbinptr   bn = size2bin(p->size);
  mchunkptr h  = &(bn->hd);
  mchunkptr f  = h->fd;

  p->bk = h;  p->fd = f;  f->bk = h->fd = p;

  if (h == f && bn > malloc_maxbin) malloc_maxbin = bn;  

  bn->dirty = 1;

   ;
}



 


 

static int* last_sbrk_end;


 


typedef volatile void (*vfp)();



extern vfp __new_handler;



static mchunkptr malloc_from_sys(unsigned nb)
{
  mchunkptr p;
  size_t       sbrk_size;
  int* ip;
  
   
   

  sbrk_size = ((nb + 4096  - 1 +                   (sizeof(size_t      ))  +                   (sizeof(size_t      )) ) 
               / 4096 ) * 4096 ;

  ip = (int*)(sbrk(sbrk_size));
  if ((char*)ip == (char*)(-1))  
  {

    (*__new_handler) ();

    return 0;
  }

   ;


  if (last_sbrk_end != &ip[-1]) 
  {                             
     
     

     
    while (!aligned_OK(ip)) { ++ip; sbrk_size -=                   (sizeof(size_t      )) ; }


     
     

    *ip++ =                   (sizeof(size_t      ))  |  0x1 ;
    
    p = (mchunkptr)ip;
    set_size(p,sbrk_size - (                  (sizeof(size_t      ))  +                   (sizeof(size_t      )) )); 
    
  }
  else 
  {
    mchunkptr l;  

     
     
     

    p = (mchunkptr)(last_sbrk_end);
    set_size(p, sbrk_size);


     

    l = ((mchunkptr)((char*)(p)-((((int*)(p))[-1]) & ~( 0x1 )))) ;
    if (!      ((l)->size &  0x1 ) )  
    {
      unlink(l);
      set_size(l, p->size + l->size);
      p = l;
    }

  }

   

  last_sbrk_end = (int*)((char*)p + p->size);
  *last_sbrk_end =                   (sizeof(size_t      ))  |  0x1 ;

   ;

   
   ;
  p->fd = p->bk = p;

  return p;
}



 
 

 
 
 
 

static mchunkptr malloc_find_space(size_t       nb)
{
  mbinptr b;

   

  while (malloc_maxbin >= (&(av[0]))  && 
         malloc_maxbin->hd.bk == &(malloc_maxbin->hd))
  {
    malloc_maxbin->dirty = 0;
    --malloc_maxbin;
  }

  for (b = malloc_maxbin; b >= (&(av[0])) ; --b)
  {
     ;

    if (b->dirty)
    {
      mchunkptr h = &(b->hd);          
      mchunkptr p = h->fd;             

      while (p != h)
      {
        mchunkptr nextp = p->fd;        
        int consolidated = 0;           

        mchunkptr t;

         ;

        while (!      ((t = ((mchunkptr)((char*)(p)-((((int*)(p))[-1]) & ~( 0x1 )))) )->size &  0x1 ) )  
        {
          if (!consolidated) { consolidated = 1; unlink(p); }
          if (t == nextp) nextp = t->fd;
          unlink(t);
          set_size(t, t->size + p->size);
          p = t;
           ;
        }
        
        while (!      ((t = ((mchunkptr)((char*)(p) + (p)->size)) )->size &  0x1 ) )  
        {
          if (!consolidated) { consolidated = 1; unlink(p); }
          if (t == nextp) nextp = t->fd;
          unlink(t);
          set_size(p, p->size + t->size);
           ;
        }

       if (consolidated)
       {
          if (p->size >= nb)
          {
             
             ;
            p->fd = p->bk = p;
            return p;
          }
          else
            consollink(p);
        }

        p = nextp;

      }

      b->dirty = 0;

    }
  }

   

  return malloc_from_sys(nb);
}



 

void* malloc(size_t       bytes)
{
  size_t       nb  = request2size(bytes);   
  mbinptr      b   = size2bin(nb);          
  mchunkptr    hd  = &(b->hd);              
  mchunkptr    p   = hd->fd;                

   ;

   
   

  while (p != hd)
  {
     ;
    if (p->size >= nb)
      goto found;
    else     
    {
      mchunkptr nextp = p->fd;        
      int consolidated = 0;           
      
      mchunkptr t;

      while (!      ((t = ((mchunkptr)((char*)(p)-((((int*)(p))[-1]) & ~( 0x1 )))) )->size &  0x1 ) )  
      {
        if (!consolidated) { consolidated = 1; unlink(p); }
        if (t == nextp) nextp = t->fd;
        unlink(t);
        set_size(t, t->size + p->size);
        p = t;
         ;
      }
      
      while (!      ((t = ((mchunkptr)((char*)(p) + (p)->size)) )->size &  0x1 ) )  
      {
        if (!consolidated) { consolidated = 1; unlink(p); }
        if (t == nextp) nextp = t->fd;
        unlink(t);
        set_size(p, p->size + t->size);
         ;
      }
      
      if (consolidated)
      {
        if (p->size >= nb)
        {
           
           ;
          p->fd = p->bk = p;
          goto found;
        }
        else
          consollink(p);
      }

      p = nextp;

    }
  }

  b->dirty = 0;  

   

  while (++b <= malloc_maxbin)
  {
     ;
    if ((p = b->hd.bk) != &(b->hd))     
      goto found;
  }

   

  p = malloc_find_space(nb);

  if (p == 0) return 0;  

 found:    

  unlink(p);
  split(p, nb); 
   ;
  return chunk2mem(p);
}




void free(void* mem)
{
  if (mem != 0)
  {
    mchunkptr p = mem2chunk(mem);
     ;
    frontlink(p);
  }
}


void* calloc(size_t       n, size_t       elem_size)
{
  size_t       sz = n * elem_size;
  void* p = malloc(sz);
  my_bzero (p, sz);
  return p;
};

 
void cfree(void *mem)
{
  free(mem);
}
 

size_t       malloc_usable_size(void* mem)
{
  if (mem == 0)
    return 0;
  else
  {
    mchunkptr p = (mchunkptr)((char*)(mem) -                   (sizeof(size_t      )) ); 
    size_t       sz = p->size & ~( 0x1 );
    if (p->size == sz || sz != *((int*)((char*)(p) + sz -                   (sizeof(size_t      )) )))
      return 0;
    else
      return sz -       (                  (sizeof(size_t      ))  +                   (sizeof(size_t      )) ) ;
  }
}



void* realloc(void* mem, size_t       bytes)
{
  if (mem == 0) 
    return malloc(bytes);
  else
  {
    size_t       nb      = request2size(bytes);
    mchunkptr    p       = mem2chunk(mem);
    size_t       oldsize = p->size;
    int          room;
    mchunkptr    nxt;

     ;
    
     

    while (!      ((nxt = ((mchunkptr)((char*)(p) + (p)->size)) )->size &  0x1 ) )
    {
       ;
      unlink(nxt);
      set_size(p, p->size + nxt->size);
    }

    room = p->size - nb;
    if (room >= 0)
    {
      split(p, nb);
       ;
      return chunk2mem(p);
    }
    else  
    {
      void* newmem;
        ((p)->size |=  0x1 ) ;     
      newmem = malloc(nb);
      my_bcopy (mem, newmem, oldsize -                   (sizeof(size_t      )) );
      free(mem);
       ;
      return newmem;
    }
  }
}



 

void* memalign(size_t       alignment, size_t       bytes)
{
  mchunkptr p;
  size_t       nb = request2size(bytes);

   
   
  size_t       align = lcm(alignment,       (                  (sizeof(size_t      ))  +                   (sizeof(size_t      )) ) );
  size_t       mask = align - 1;

   
   

  size_t       req = nb + align + (sizeof(struct malloc_chunk) +                   (sizeof(size_t      )) ) ;
  void* m = malloc(req);

  if (m == 0) return m;

  p = mem2chunk(m);

   

   ;
   ;
   ;
   ;

  if (((int)(m) & (mask)) != 0)  
  {

     

    mchunkptr ap = (mchunkptr)(( ((int)(m) + mask) & -align) -                   (sizeof(size_t      )) );

    size_t       gap = (size_t      )(ap) - (size_t      )(p);
    size_t       room;

     

    if (gap < (sizeof(struct malloc_chunk) +                   (sizeof(size_t      )) ) )
    {
       
       

      ap = (mchunkptr)( (int)(ap) + align );
      gap += align;    
    }

    if (gap + nb > p->size)  
      malloc_user_error();

    room = p->size - gap;

     
    set_size(p, gap);
    consollink(p);

     
    p = ap;
    set_size(p, room);
  }

   

  split(p, nb); 
   ;
  return chunk2mem(p);

}


# 1 "../include/getpagesize.h" 1 3








# 1 "/usr/include/sys/param.h" 1 3
 

 



























 















































































 

 







# 1 "/usr/include/ansi_compat.h" 1 3
 



 





















 

















# 116 "/usr/include/ansi_compat.h" 3

# 121 "/usr/include/sys/param.h" 2 3

# 1 "/usr/include/machine/param.h" 1 3
 



 



























 
 
 
 
 
 
 

 




























 



 






























 


 



 




 


 


 




extern unsigned int sr_usermask;



 







# 122 "/usr/include/sys/param.h" 2 3








 







 





# 164 "/usr/include/sys/param.h" 3
















 




 






				 
				 
				 
				 

 



 






















 















 


 






# 1 "/usr/include/signal.h" 1 3
 

 


























 











































# 1 "/usr/include/ansi_compat.h" 1 3
 



 





















 

















# 116 "/usr/include/ansi_compat.h" 3

# 74 "/usr/include/signal.h" 2 3


















					 
 



















 







































 







 


















 

typedef long	sig_atomic_t;
typedef int sigset_t;	 


 


struct	sigvec {
	void	 (*sv_handler)();	 
	sigset_t sv_mask;		 
	int	sv_flags;		 
};


 



struct	sigaction {
	void	 (*sa_handler)();	 
	sigset_t sa_mask;		 
	int	 sa_flags;		 
};














 







 


struct	sigstack {
	char	*ss_sp;			 
	int	ss_onstack;		 
};

 















struct	sigcontext {

	 




	int	sc_onstack;		 
	int	sc_mask;		 






	int	sc_pc;			 
	 


	int	sc_regs[32];	 
	int	sc_mdlo;	 
	int	sc_mdhi;	 
	 


	int	sc_ownedfp;	 
	int	sc_fpregs[32];	 
	int	sc_fpc_csr;	 
	int	sc_fpc_eir;	 
	 



	 


	int	sc_cause;	 
	int	sc_badvaddr;	 
	int	sc_badpaddr;	 

};























 



extern void	(*signal(int __sig, void(*__func)(int)))(int);
int	raise( int __sig );
int 	kill( pid_t __pid, int __sig );
int 	sigemptyset( sigset_t *__set );
int 	sigfillset( sigset_t *__set );
int 	sigaddset( sigset_t *__set, int __signo );
int	sigdelset( sigset_t *__set, int __signo );
int	sigismember( const sigset_t *__set, int __signo );
int 	sigaction( int __sig, const struct sigaction *__act,
		struct sigaction *__oact );
int 	sigprocmask( int __how, const sigset_t *__set, sigset_t *__oset );
int	sigpending( sigset_t *__set );
int	sigsuspend( const sigset_t *__sigmask );











 









# 250 "/usr/include/sys/param.h" 2 3








 






 




 

























 
















# 1 "/usr/include/sys/smp_lock.h" 1 3
 

 



























 





















































































 








# 1 "/usr/include/ansi_compat.h" 1 3
 



 





















 

















# 116 "/usr/include/ansi_compat.h" 3

# 126 "/usr/include/sys/smp_lock.h" 2 3










 

















 



struct __lock_t {
	volatile unsigned int
			l_call:8,	 
			l_hierpos:8,	 
			l_ipl:8,	 
			l_type:7,	 
			l_lock:1;	 
	struct __lock_t	*l_plock;	 
	char *		l_pc;
	unsigned long 	l_lost; 	 
	unsigned long 	l_spin;		 
	unsigned long 	l_won;		 
	unsigned short 	l_wanted;	 

};




 



struct lock_trace {
	long tr_pid;	 
	caddr_t tr_pc;	 
	long tr_psl;	 
	struct __lock_t  *tr_lock;	 
};



struct debug_entry {
		unsigned int spinct;
		caddr_t calling_pc;
		caddr_t holding_pc;
	};
struct debug_lock_trace {
	struct __lock_t  *traced_lock;
	int current_lock_trace;	
	int debug_lock_entries;
	struct debug_entry element[200 ];
};

extern struct debug_lock_trace *debug_lock_trace;

 
struct lock_data {
	char	l_hierpos;
	char	l_type;
	char	l_ipl;
};

# 384 "/usr/include/sys/smp_lock.h" 3




# 313 "/usr/include/sys/param.h" 2 3







 






























 







 












 





 







 





 





# 9 "../include/getpagesize.h" 2 3

















# 1182 "malloc.c" 2



static size_t       malloc_pagesize = 0;

void* valloc(size_t       bytes)
{
  if (malloc_pagesize == 0) malloc_pagesize = 	4096		 * 	1  ;
  return memalign (malloc_pagesize, bytes);
}
    

void malloc_stats()
{

}
# 1277 "malloc.c"

 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads