newlib/winsup/cygwin/uname.cc

116 lines
3.2 KiB
C++
Raw Normal View History

2000-02-17 20:38:33 +01:00
/* uname.cc
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
2000-02-17 20:38:33 +01:00
Written by Steve Chamberlain of Cygnus Support, sac@cygnus.com
Rewritten by Geoffrey Noer of Cygnus Solutions, noer@cygnus.com
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
2000-02-17 20:38:33 +01:00
#include <stdio.h>
#include <sys/utsname.h>
#include "cygwin_version.h"
#include "cygtls.h"
2000-02-17 20:38:33 +01:00
/* uname: POSIX 4.4.1.1 */
extern "C" int
2000-02-17 20:38:33 +01:00
uname (struct utsname *name)
{
SYSTEM_INFO sysinfo;
myfault efault;
if (efault.faulted (EFAULT))
return -1;
2001-11-05 07:09:15 +01:00
char *snp = strstr (cygwin_version.dll_build_date, "SNP");
2000-02-17 20:38:33 +01:00
2000-02-28 07:21:07 +01:00
memset (name, 0, sizeof (*name));
__small_sprintf (name->sysname, "CYGWIN_%s", wincap.osname ());
2000-02-17 20:38:33 +01:00
#if 0
/* Recognition of the real 64 bit CPU inside of a WOW64 system, irritates
build systems which think the native system is a 64 bit system. Since
we're actually running in a 32 bit environment, it looks more correct
just to use the CPU info given by WOW64. */
if (wincap.is_wow64 ())
GetNativeSystemInfo (&sysinfo);
else
#else
/* But it seems ok to add a hint to the sysname, that we're running under
WOW64. This might give an early clue if somebody encounters problems. */
if (wincap.is_wow64 ())
strncat (name->sysname, "-WOW64",
sizeof name->sysname - strlen (name->sysname) - 1);
#endif
GetSystemInfo (&sysinfo);
2000-02-17 20:38:33 +01:00
/* Computer name */
cygwin_gethostname (name->nodename, sizeof (name->nodename) - 1);
2000-02-17 20:38:33 +01:00
/* Cygwin dll release */
__small_sprintf (name->release, "%d.%d.%d%s(%d.%d/%d/%d)",
2000-02-17 20:38:33 +01:00
cygwin_version.dll_major / 1000,
cygwin_version.dll_major % 1000,
cygwin_version.dll_minor,
snp ? "s" : "",
2000-02-17 20:38:33 +01:00
cygwin_version.api_major,
cygwin_version.api_minor,
cygwin_version.shared_data,
cygwin_version.mount_registry);
/* Cygwin "version" aka build date */
strcpy (name->version, cygwin_version.dll_build_date);
if (snp)
name->version[snp - cygwin_version.dll_build_date] = '\0';
2000-02-17 20:38:33 +01:00
/* CPU type */
switch (sysinfo.wProcessorArchitecture)
{
case PROCESSOR_ARCHITECTURE_INTEL:
unsigned int ptype;
if (wincap.has_valid_processorlevel ())
{
if (sysinfo.wProcessorLevel < 3) /* Shouldn't happen. */
ptype = 3;
else if (sysinfo.wProcessorLevel > 9) /* P4 */
ptype = 6;
else
ptype = sysinfo.wProcessorLevel;
}
else
{
if (sysinfo.dwProcessorType == PROCESSOR_INTEL_386 ||
* autoload.cc (LoadFuncEx): Define via new LoadFuncEx2 macro. (LoadFuncEx2): Adapted from LoadFuncEx. Provides control of return value for nonexistent function. (NtQueryObject): Declare. (IsDebuggerPresent): Declare via LoadFuncEx2 and always return true if not available. * debug.h (being_debugged): Just rely on IsDebuggerPresent return value. * dtable.cc (handle_to_fn): New function. (dtable::init_std_file_from_handle): Attempt to derive std handle's name via handle_to_fn. (dtable::build_fhandler_from_name): Fill in what we can in path_conv structure when given a handle and path doesn't exist. * fhandler.cc (fhandler_base::open): Don't set the file pointer here. Use pc->exists () to determine if file exists rather than calling GetFileAttributes again. * fhandler.h (fhandler_base::exec_state_isknown): New method. (fhandler_base::fstat_helper): Add extra arguments to declaration. (fhandler_base::fstat_by_handle): Declare new method. (fhandler_base::fstat_by_name): Declare new method. * fhandler_disk_file (num_entries): Make __stdcall. (fhandler_base::fstat_by_handle): Define new method. (fhandler_base::fstat_by_name): Define new method. (fhandler_base:fstat): Call fstat_by_{handle,name} as appropriate. (fhandler_disk_file::fstat_helper): Accept extra arguments for filling out stat structure. Move handle or name specific stuff to new methods above. (fhandler_disk_file::open): Use real_path->exists rather than calling GetFileAttributes again. * ntdll.h (FILE_NAME_INFORMATION): Define new structure. (OBJECT_INFORMATION_CLASS): Partially define new enum. (OBJECT_NAME_INFORMATION): Define new structure. (NtQueryInformationFile): New declaration. (NtQueryObject): New declaration. * path.cc (path_conv::fillin): Define new method. * path.h (path_conv::fillin): Declare new method. (path_conv::drive_thpe): Rename from 'get_drive_type'. (path_conv::volser): Declare new method. (path_conv::volname): Declare new method. (path_conv::root_dir): Declare new method. * syscalls.cc (fstat64): Send real path_conv to fstat as second argument.
2002-05-28 03:55:40 +02:00
sysinfo.dwProcessorType == PROCESSOR_INTEL_486)
ptype = sysinfo.dwProcessorType / 100;
else
ptype = PROCESSOR_INTEL_PENTIUM / 100;
}
__small_sprintf (name->machine, "i%d86", ptype);
2000-02-17 20:38:33 +01:00
break;
case PROCESSOR_ARCHITECTURE_IA64:
strcpy (name->machine, "ia64");
break;
case PROCESSOR_ARCHITECTURE_AMD64:
strcpy (name->machine, "x86_64");
break;
case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
strcpy (name->machine, "ia32-win64");
2005-06-06 17:58:08 +02:00
break;
2000-02-17 20:38:33 +01:00
case PROCESSOR_ARCHITECTURE_ALPHA:
strcpy (name->machine, "alpha");
break;
case PROCESSOR_ARCHITECTURE_MIPS:
strcpy (name->machine, "mips");
break;
default:
strcpy (name->machine, "unknown");
break;
}
return 0;
}