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:
Enrico Weigelt, metux IT consult 2024-02-14 17:59:08 +01:00 committed by Marge Bot
parent 02b5696e2b
commit 77f9792911
2 changed files with 11 additions and 12 deletions

View File

@ -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) {

View File

@ -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_ */