foo
[bootcensus] / src / libc / unistd.c
index 1fc0542..7da132f 100644 (file)
@@ -19,6 +19,8 @@ along with this program.  If not, see <https://www.gnu.org/licenses/>.
 #include <errno.h>
 #include "unistd.h"
 #include "fs.h"
+#include "timer.h"
+#include "asmops.h"
 
 int chdir(const char *path)
 {
@@ -59,3 +61,13 @@ int rmdir(const char *path)
        fs_close(fsn);
        return 0;
 }
+
+int usleep(unsigned long usec)
+{
+       unsigned long wait_ticks = MSEC_TO_TICKS(usec / 1000ul);
+       unsigned long start_ticks = nticks;
+       while(nticks - start_ticks < wait_ticks) {
+               halt_cpu();
+       }
+       return 0;
+}