Subject: Re: new sysctl(KERN_PROC, ...) interface (was: sysinfo(2))
To: Simon Burge <simonb@netbsd.org>
From: Darren Reed <darrenr@reed.wattle.id.au>
List: tech-kern
Date: 04/19/2000 23:47:16
In some email I received from Simon Burge, sie wrote:
> Eduardo Horvath wrote:
> 
> > On Tue, 18 Apr 2000, Simon Burge wrote:
> > 
> > >  3) Need the size of "char **" for same reasons as 2).
> > > 
> > >     Is there an easy way to tell if a process is a 32 or 64 bit process?
> > 
> > No.  But I added a P_32 flag to the proc struct to indicate that a process
> > is running under 32-bit emulation.
> 
> So for the 32 bit emul case, you'd need to know the possibility that
> you might be running under emulation, which isn't really possible (eg,
> mips ps today, with mips64 maybe occuring one day).  But if we stored
> the kernel's idea of the pointer size and looking at P_32 if the pointer
> size is 8 bytes then we should be able to cover all possibilities...
> 
> sysctl HW_KERNPTRSIZE ?

I don't see anything in Solaris7 but HP-UX 11.0 has the following
for sysconf():

HW_32_64_CAPABLE  _SC_HW_32_64_CAPABLE   Returns which kernel is supported
                                         on the hardware.  The value returned
                                         is an encoding which may be
                                         interpreted using the
                                         _SYSTEM_SUPPORTS_ILP32OS() and
                                         _SYSTEM_SUPPORTS_LP64OS() macros
                                         defined in unistd.h.  Example:

                                         long ret = sysconf(_SC_HW_32_64_CAPABLE);

                                         if (_SYSTEM_SUPPORTS_ILP32OS(ret) != 0) {
                                         /* system supports 32-bit OS */
                                         }

                                         if (_SYSTEM_SUPPORTS_LP64OS(ret) != 0) {
                                         /* system supports 64-bit OS */
                                         }


KERNEL_BITS       _SC_KERNEL_BITS        Returns the number of bits used by
                                         the kernel for pointer and long
                                         data types.  Current values include
                                         32 and 64.


And then, whilst running under a 32bit kernel (8000/900/D390):

# getconf HW_32_64_CAPABLE
3
# getconf KERNEL_BITS
32

with a 64bit kernel (8000/900/D390):

# getconf HW_32_64_CAPABLE
3
# getconf KERNEL_BITS
64

Darren