os: simplify win32 uname()
Just define struct utsname and a tiny uname() function instead of cluttering the code with ifdef's. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1295>
This commit is contained in:
parent
02b5696e2b
commit
77f9792911
12
os/access.c
12
os/access.c
|
@ -446,15 +446,7 @@ DefineSelf(int fd)
|
|||
caddr_t addr;
|
||||
int family;
|
||||
register HOST *host;
|
||||
|
||||
#ifndef WIN32
|
||||
struct utsname name;
|
||||
#else
|
||||
struct {
|
||||
char nodename[512];
|
||||
} name;
|
||||
#endif
|
||||
|
||||
register struct hostent *hp;
|
||||
|
||||
union {
|
||||
|
@ -480,11 +472,7 @@ DefineSelf(int fd)
|
|||
* uname() lets me access to the whole string (it smashes release, you
|
||||
* see), whereas gethostname() kindly truncates it for me.
|
||||
*/
|
||||
#ifndef WIN32
|
||||
uname(&name);
|
||||
#else
|
||||
gethostname(name.nodename, sizeof(name.nodename));
|
||||
#endif
|
||||
|
||||
hp = _XGethostbyname(name.nodename, hparams);
|
||||
if (hp != NULL) {
|
||||
|
|
11
os/osdep.h
11
os/osdep.h
|
@ -133,4 +133,15 @@ extern void GenerateRandomData(int len, char *buf);
|
|||
void TimerInit(void);
|
||||
Bool TimerForce(OsTimerPtr timer);
|
||||
|
||||
#ifdef WIN32
|
||||
#include <X11/Xwinsock.h>
|
||||
struct utsname {
|
||||
char nodename[512];
|
||||
};
|
||||
|
||||
static inline void uname(struct utsname *uts) {
|
||||
gethostname(uts->nodename, sizeof(uts->nodename));
|
||||
}
|
||||
#endif /* WIN32 */
|
||||
|
||||
#endif /* _OSDEP_H_ */
|
||||
|
|
Loading…
Reference in New Issue