#11073: remove the spkg/base repo?
---------------------------+------------------------------------------------
   Reporter:  jhpalmieri   |       Owner:  GeorgSWeber    
       Type:  enhancement  |      Status:  new            
   Priority:  blocker      |   Milestone:  sage-4.7.1     
  Component:  build        |    Keywords:  scripts base hg
     Author:               |    Upstream:  N/A            
   Reviewer:               |      Merged:                 
Work_issues:               |  
---------------------------+------------------------------------------------

Comment(by drkirkby):

 Replying to [comment:8 jdemeyer]:
 > Replying to [comment:7 drkirkby]:
 > > It's pretty dumb, as it forces a long to be 4 bytes with:
 > >
 > > {{{
 > > typedef unsigned long       int_fast32_t;
 > > }}}
 > >
 > > which is obviously invalid on 64-bit builds.
 >
 > It is invalid, but not for the reason you state.
 >
 > The problem is that `int_fast32_t` is supposed to be '''signed''', while
 `unsigned long` is '''unsigned'''.  As for size, the type `int_fast32_t`
 is required to be ''at least'' 32 bits, not ''exactly'' 32 bits, so the
 following would be correct, both on 32-bit and 64-bit machines:
 > {{{
 > typedef long            int_fast32_t;
 > }}}

 On Solaris the int_fast_32 remains at 32-bits, even on 64-bit code, so
 what actually caused Sage to fail to compile was certainly the size rather
 than the sign.

 That little bit of header file was included in Sage well after Sage built
 reliably 32-bit. It was only when I tried a 64-bit build of Sage that this
 became a problem. (I think a 64-bit Sage on Solaris is looking further
 away now, as we don't have a good solution for making sure modules are
 initialized properly before anything is imported from them.)

 == Test program ==
 {{{
 drkirkby@laptop:~$ cat test.c
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/int_types.h>

 int main() {
   printf("sizeof(int)=%d\n",sizeof(int));
   printf("sizeof(long)=%d\n",sizeof(long));
   printf("sizeof(int_fast32_t)=%d\n",sizeof(int_fast32_t));
   exit(0);
 }
 }}}
 == Create a 32-bit executable and execute it ==
 {{{
 drkirkby@laptop:~$ gcc  test.c
 drkirkby@laptop:~$ ./a.out
 sizeof(int)=4
 sizeof(long)=4
 sizeof(int_fast32_t)=4
 }}}
 == Create a 64-bit executable and execute it ==
 {{{
 drkirkby@laptop:~$ gcc  -m64 test.c
 drkirkby@laptop:~$ ./a.out
 sizeof(int)=4
 sizeof(long)=8
 sizeof(int_fast32_t)=4
 }}}

 > In fact, on my 64-bit Linux laptop, the types `int_fast16_t` and
 `int_fast32_t` are `typedef`ed to be 64-bit `long`s.

 As you can see, that's not so on Solaris, int_fast32_t remains 32-bits,
 even in 64-bit code.

 I recall using a Cray Y-MP with Unicos, where
 {{{
 sizeof(char)=1
 sizeof(short)=8
 sizeof(int)=8
 sizeof(long)=8
 }}}
 The Cray is the only system I've come across where shorts are 64-bit. That
 tripped me up, as some code I'd written assumed shorts were 2 bytes.

 Dave

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11073#comment:13>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to