a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#ifndef _UNISTD_H
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define _UNISTD_H
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncFILE_LICENCE ( GPL2_OR_LATER );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#include <stddef.h>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#include <stdarg.h>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncextern int execv ( const char *command, char * const argv[] );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Execute command
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v command Command name
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @v arg ... Argument list (starting with argv[0])
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @ret rc Command exit status
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * This is a front end to execv().
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#define execl( command, arg, ... ) ( { \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync char * const argv[] = { (arg), ## __VA_ARGS__ }; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync int rc = execv ( (command), argv ); \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync rc; \
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync } )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/* Pick up udelay() */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#include <ipxe/timer.h>
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/*
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * sleep() prototype is defined by POSIX.1. usleep() prototype is
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * defined by 4.3BSD. udelay() and mdelay() prototypes are chosen to
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * be reasonably sensible.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncextern unsigned int sleep ( unsigned int seconds );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncextern void mdelay ( unsigned long msecs );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncstatic inline __always_inline void usleep ( unsigned long usecs ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync udelay ( usecs );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync}
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync#endif /* _UNISTD_H */