ExternalBytes.st
changeset 8913 b9498d27a554
parent 8908 68017b13590b
child 8919 707a9ff7f9b2
equal deleted inserted replaced
8912:3d1947a79cf3 8913:b9498d27a554
    26 	char *chunk;
    26 	char *chunk;
    27 	unsigned size;
    27 	unsigned size;
    28 	struct mallocList *next;
    28 	struct mallocList *next;
    29 };
    29 };
    30 static struct mallocList *mallocList = (struct mallocList *)0;
    30 static struct mallocList *mallocList = (struct mallocList *)0;
    31 static mallocCount = 0;
    31 static INT mallocCount = 0;
    32 
    32 
    33 static void
    33 static void
    34 removeFromMallocList(ptr)
    34 removeFromMallocList(ptr)
    35     char *ptr;
    35     char *ptr;
    36 {
    36 {
   562     "
   562     "
   563 !
   563 !
   564 
   564 
   565 numberOfAllocatedChunks
   565 numberOfAllocatedChunks
   566 %{  /* NOCONTEXT */
   566 %{  /* NOCONTEXT */
   567     RETURN ( __MKSMALLINT(mallocCount) );
   567     RETURN ( __mkSmallInteger(mallocCount) );
   568 %}
   568 %}
   569     "
   569     "
   570      self numberOfAllocatedChunks
   570      self numberOfAllocatedChunks
   571     "
   571     "
   572 ! !
   572 ! !
   584 
   584 
   585 sizeofDouble
   585 sizeofDouble
   586     "return the number of bytes used by the machines native doubles"
   586     "return the number of bytes used by the machines native doubles"
   587 
   587 
   588 %{  /* NOCONTEXT */
   588 %{  /* NOCONTEXT */
   589     RETURN (__MKSMALLINT( sizeof(double)));
   589     RETURN (__mkSmallInteger( sizeof(double)));
   590 %}
   590 %}
   591     "
   591     "
   592      ExternalBytes sizeofDouble
   592      ExternalBytes sizeofDouble
   593     "
   593     "
   594 !
   594 !
   595 
   595 
   596 sizeofFloat
   596 sizeofFloat
   597     "return the number of bytes used by the machines native floats"
   597     "return the number of bytes used by the machines native floats"
   598 
   598 
   599 %{  /* NOCONTEXT */
   599 %{  /* NOCONTEXT */
   600     RETURN (__MKSMALLINT( sizeof(float)));
   600     RETURN (__mkSmallInteger( sizeof(float)));
   601 %}
   601 %}
   602     "
   602     "
   603      ExternalBytes sizeofFloat
   603      ExternalBytes sizeofFloat
   604     "
   604     "
   605 !
   605 !
   606 
   606 
   607 sizeofInt
   607 sizeofInt
   608     "return the number of bytes used by the machines native integer"
   608     "return the number of bytes used by the machines native integer"
   609 
   609 
   610 %{  /* NOCONTEXT */
   610 %{  /* NOCONTEXT */
   611     RETURN (__MKSMALLINT( sizeof(int)));
   611     RETURN (__mkSmallInteger( sizeof(int)));
   612 %}
   612 %}
   613     "
   613     "
   614      ExternalBytes sizeofInt
   614      ExternalBytes sizeofInt
   615     "
   615     "
   616 !
   616 !
   617 
   617 
   618 sizeofLong
   618 sizeofLong
   619     "return the number of bytes used by the machines native longs"
   619     "return the number of bytes used by the machines native longs"
   620 
   620 
   621 %{  /* NOCONTEXT */
   621 %{  /* NOCONTEXT */
   622     RETURN (__MKSMALLINT( sizeof(long)));
   622     RETURN (__mkSmallInteger( sizeof(long)));
   623 %}
   623 %}
   624     "
   624     "
   625      ExternalBytes sizeofLong
   625      ExternalBytes sizeofLong
   626     "
   626     "
   627 !
   627 !
   628 
   628 
   629 sizeofPointer
   629 sizeofPointer
   630     "return the number of bytes used by the machines native pointer"
   630     "return the number of bytes used by the machines native pointer"
   631 
   631 
   632 %{  /* NOCONTEXT */
   632 %{  /* NOCONTEXT */
   633     RETURN (__MKSMALLINT( sizeof(char *)));
   633     RETURN (__mkSmallInteger( sizeof(char *)));
   634 %}
   634 %}
   635     "
   635     "
   636      ExternalBytes sizeofPointer
   636      ExternalBytes sizeofPointer
   637     "
   637     "
   638 !
   638 !
   639 
   639 
   640 sizeofShort
   640 sizeofShort
   641     "return the number of bytes used by the machines native short"
   641     "return the number of bytes used by the machines native short"
   642 
   642 
   643 %{  /* NOCONTEXT */
   643 %{  /* NOCONTEXT */
   644     RETURN (__MKSMALLINT( sizeof(short)));
   644     RETURN (__mkSmallInteger( sizeof(short)));
   645 %}
   645 %}
   646     "
   646     "
   647      ExternalBytes sizeofShort
   647      ExternalBytes sizeofShort
   648     "
   648     "
   649 ! !
   649 ! !
   653 address
   653 address
   654     "return the start address as an integer"
   654     "return the start address as an integer"
   655 
   655 
   656 %{  /* NOCONTEXT */
   656 %{  /* NOCONTEXT */
   657 
   657 
   658     int addr;
   658     INT addr;
   659 
   659 
   660     if (__INST(address_) != nil) {
   660     if (__INST(address_) != nil) {
   661 	addr = (INT)__INST(address_);
   661 	addr = (INT)__INST(address_);
   662 	if (addr <= _MAX_INT) {
   662 	if (addr <= _MAX_INT) {
   663 	    RETURN ( __MKSMALLINT(addr) );
   663 	    RETURN ( __mkSmallInteger(addr) );
   664 	}
   664 	}
   665 	RETURN ( __MKUINT(addr));
   665 	RETURN ( __MKUINT(addr));
   666     }
   666     }
   667 %}.
   667 %}.
   668     ^ nil
   668     ^ nil
   683 	idx = __intVal(index);
   683 	idx = __intVal(index);
   684 	if (idx > 0) {
   684 	if (idx > 0) {
   685 	    if (((sz = __INST(size)) == nil)
   685 	    if (((sz = __INST(size)) == nil)
   686 	     || (__intVal(sz) >= idx)) {
   686 	     || (__intVal(sz) >= idx)) {
   687 		cp = cp + idx - 1;
   687 		cp = cp + idx - 1;
   688 		RETURN ( __MKSMALLINT(*cp) );
   688 		RETURN ( __mkSmallInteger((*cp)) );
   689 	    }
   689 	    }
   690 	}
   690 	}
   691     }
   691     }
   692 %}.
   692 %}.
   693     (size notNil and:[self address notNil]) ifTrue:[
   693     (size notNil and:[self address notNil]) ifTrue:[
  1240 ! !
  1240 ! !
  1241 
  1241 
  1242 !ExternalBytes class methodsFor:'documentation'!
  1242 !ExternalBytes class methodsFor:'documentation'!
  1243 
  1243 
  1244 version
  1244 version
  1245     ^ '$Header: /cvs/stx/stx/libbasic/ExternalBytes.st,v 1.58 2005-07-08 14:00:04 cg Exp $'
  1245     ^ '$Header: /cvs/stx/stx/libbasic/ExternalBytes.st,v 1.59 2005-07-08 17:15:01 cg Exp $'
  1246 ! !
  1246 ! !
  1247 
  1247 
  1248 ExternalBytes initialize!
  1248 ExternalBytes initialize!