@@ -79,16 +79,15 @@ __STDPP__directive pragma pp:hide getdomainname gethostid gethostname sethostnam
7979
8080#include
8181#include
82+ #include
82838384
8485#include "FEATURE/utsname"
8586
8687#define MAXHOSTNAME 64
8788
8889#if _lib_uname && _sys_utsname
89-
90- #include
91-
90+ # include
9291#endif
9392
9493#if defined(__STDPP__directive ) && defined(__STDPP__hide )
@@ -269,6 +268,9 @@ b_uname(int argc, char** argv, Shbltin_t* context)
269268 {
270269 case 'a' :
271270 flags |= OPT_all |((1L <<OPT_ALL )- 1 );
271+ #ifdef __linux__
272+ flags |= OPT_implementation ;
273+ #endif
272274 continue ;
273275 case 'b' :
274276 flags |= OPT_base ;
@@ -394,13 +396,56 @@ b_uname(int argc, char** argv, Shbltin_t* context)
394396 output (OPT_machine , ut .machine , "machine" );
395397 if (flags & OPT_processor )
396398 {
397- if (!* (s = astconf ("ARCHITECTURE" , NiL , NiL )))
399+ s = NULL ;
400+ #ifdef __linux__
401+ # ifdef UNAME_PROCESSOR
402+ if (!s )
403+ {
404+ size_t len = sizeof (buf ) - 1 ;
405+ int ctl [] = {CTL_HW , UNAME_PROCESSOR };
406+ if (sysctl (ctl , 2 , buf , & len , 0 , 0 ) == 0 )
407+ s = buf ;
408+ }
409+ # endif
410+ if (!s )
411+ {
412+ strcpy ((s = buf ), ut .machine );
413+ if (strcmp (s , "i686" ) == 0 )
414+ {
415+ char line [1024 ];
416+ Sfio_t * io = sfopen ((Sfio_t * )0 , "/proc/cpuinfo" , "r" );
417+ if (io )
418+ {
419+ while (fgets (line , sizeof (line ), io ) > 0 )
420+ {
421+ if (strncmp (line , "vendor_id" , 9 ) == 0 )
422+ {
423+ if (strstr (line , "AuthenticAMD" ))
424+ s = "athlon" ;
425+ break ;
426+ }
427+ }
428+ sfclose (io );
429+ }
430+ }
431+ }
432+ #endif
433+ if (!s && !* (s = astconf ("ARCHITECTURE" , NiL , NiL )))
398434 s = ut .machine ;
399435 output (OPT_processor , s , "processor" );
400436 }
401437 if (flags & OPT_implementation )
402438 {
403- if (!* (s = astconf ("PLATFORM" , NiL , NiL )) && !* (s = astconf ("HW_NAME" , NiL , NiL )))
439+ s = NULL ;
440+ #ifdef __linux__
441+ if (!s )
442+ {
443+ strcpy ((s = buf ), ut .machine );
444+ if (s [0 ] == 'i' && s [2 ] == '8' && s [3 ] == '6' && s [4 ] == '\0' )
445+ s [1 ] = '3' ;
446+ }
447+ #endif
448+ if (!s && !* (s = astconf ("PLATFORM" , NiL , NiL )) && !* (s = astconf ("HW_NAME" , NiL , NiL )))
404449 {
405450 if (t = strchr (hosttype , '.' ))
406451 t ++ ;
0 commit comments