~ubuntu-branches/ubuntu/vivid/atlas/vivid

« back to all changes in this revision

Viewing changes to CONFIG/src/backend/archinfo_aix.c

  • Committer: Package Import Robot
  • Author(s): Sébastien Villemot
  • Date: 2013-06-11 15:58:16 UTC
  • mfrom: (1.1.3 upstream)
  • mto: (2.2.21 experimental)
  • mto: This revision was merged to the branch mainline in revision 26.
  • Revision ID: package-import@ubuntu.com-20130611155816-b72z8f621tuhbzn0
Tags: upstream-3.10.1
Import upstream version 3.10.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
   enum ARCHFAM fam;
57
57
   enum MACHTYPE mach=MACHOther;
58
58
   int ierr, i;
59
 
   char res[1024];
 
59
   char *res;
60
60
 
61
61
   fam = ProbeArchFam(NULL);
62
62
   switch(fam)
63
63
   {
64
64
   case AFPPC: /* don't know */
65
 
      if (!CmndOneLine(NULL, "/usr/sbin/prtconf | fgrep 'Processor Type'", res))
 
65
      res = atlsys_1L(NULL, "/usr/sbin/prtconf | fgrep 'Processor Type'", 0, 0);
 
66
      if (res)
66
67
      {
67
68
         if (strstr(res, "PowerPC_POWER5"))
68
69
            mach = IbmPwr5;
72
73
            mach = IbmPwr6;
73
74
         else if (strstr(res, "PowerPC_POWER4"))
74
75
            mach = IbmPwr4;
 
76
         free(res);
75
77
      }
76
78
      break;
77
79
   }
78
80
   return(mach);
79
81
}
80
 
 
81
82
int ProbeNCPU()
82
83
{
83
84
   int ncpu = 0;
84
 
   char *reslns, res[1024];
 
85
   char *res;
85
86
 
86
 
   if (!CmndOneLine(NULL, "/usr/sbin/prtconf | fgrep 'Number Of Processors'",
87
 
                    res))
 
87
   res = atlsys_1L(NULL, "/usr/sbin/prtconf | fgrep 'Number Of Processors'",
 
88
                   0, 0);
 
89
   if (res)
 
90
   {
88
91
      ncpu = GetLastInt(res);
 
92
      free(res);
 
93
   }
89
94
   return(ncpu);
90
95
}
91
96
 
92
97
int ProbePointerBits(int *sure)
93
98
{
94
 
   int iret = 32;
 
99
   int i;
95
100
   char *uname;
96
 
   char cmnd[1024], res[1024];
 
101
   char *cmnd, *res;
97
102
 
98
103
   *sure = 0;
99
104
/*
100
 
 * Note this is a weak probe, archinfo_x86 much better . . .
101
 
 */
102
 
   uname = FindUname(NULL);
103
 
   sprintf(cmnd, "%s -a", uname);
104
 
/*
105
105
 * This probe should be running on backend; if its ptr length is 8, we've
106
106
 * definitely got a 64 bit machine
107
107
 * NOTE: getting 4 could be a result of compiler flags on a 64-bit arch,
109
109
 */
110
110
   if (sizeof(void*) == 8)
111
111
   {
112
 
      iret = 64;
113
112
      *sure = 1;
 
113
      return(64);
114
114
   }
115
115
 
116
 
   else if (!CmndOneLine(NULL, "/usr/sbin/prtconf | fgrep 'Kernel Type'", res))
 
116
   res = atlsys_1L(NULL, "/usr/sbin/prtconf | fgrep 'Kernel Type'", 0, 0);
 
117
   if (res)
117
118
   {
118
119
      if (GetLastInt(res) == 64)
119
120
      {
120
 
         iret = 64;
121
121
         *sure = 1;
 
122
         free(res);
 
123
         return(64);
122
124
      }
 
125
      free(res);
123
126
   }
124
 
   else if (!CmndOneLine(NULL, cmnd, res))
 
127
/*
 
128
 * Note this is a weak probe, archinfo_x86 much better . . .
 
129
 */
 
130
   uname = FindUname(NULL);
 
131
   i = strlen(uname) + 4;
 
132
   cmnd = malloc(sizeof(char)*i);
 
133
   assert(cmnd);
 
134
   sprintf(cmnd, "%s -a", uname);
 
135
 
 
136
   res = atlsys_1L(NULL, cmnd, 0, 0);
 
137
   free(cmnd);
 
138
   if (res)
125
139
   {
126
140
/*
127
141
 *    If uname is a known 64-bit platform, we're sure we've got OS support
129
143
 */
130
144
      if (strstr(res, "x86_64") || strstr(res, "ppc64") || strstr(res, "ia64"))
131
145
      {
132
 
         iret = 64;
133
146
         *sure = 1;
 
147
         free(res);
 
148
         return(64);
134
149
      }
 
150
      free(res);
135
151
   }
136
 
   return(iret);
 
152
   return(32);
137
153
}
138
154
 
139
155
int ProbeMhz()
140
156
{
141
157
   int mhz=0;
142
 
   char res[1024];
143
 
   if (!CmndOneLine(NULL, "/usr/sbin/prtconf | fgrep 'Processor Clock Speed'",
144
 
                    res))
 
158
   char *res;
 
159
   res = atlsys_1L(NULL, "/usr/sbin/prtconf | fgrep 'Processor Clock Speed'",
 
160
                   0, 0);
 
161
   if (res)
 
162
   {
145
163
      mhz = GetLastInt(res);  /* assumes clock speed always given in MHz */
 
164
      free(res);
 
165
   }
146
166
   return(mhz);
147
167
}
148
168