From: Jinkun Jang Date: Tue, 12 Mar 2013 16:45:24 +0000 (+0900) Subject: Tizen 2.1 base X-Git-Tag: 2.1b_release~1 X-Git-Url: http://review.tizen.org/git/?p=external%2Fusleep.git;a=commitdiff_plain;h=4ef1fdb06d56bbf980699732f12063356145ec3d Tizen 2.1 base --- diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4c85695 --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +CFLAGS += $(RPM_OPT_FLAGS) -Wall -D_GNU_SOURCE + +PROGS = usleep +mandir = /usr/share/man + +all: $(PROGS) + +clean: + rm -f $(PROGS) *.o + +install: + mkdir -p $(DESTDIR)/bin + install -m 755 usleep $(DESTDIR)/bin/usleep + mkdir -p $(DESTDIR)/$(mandir)/man1 + install -m 644 usleep.1 $(DESTDIR)/$(mandir)/man1/ + +USLEEP_OBJS = usleep.o +usleep: $(USLEEP_OBJS) + $(CC) $(LDFLAGS) -o $@ $(USLEEP_OBJS) -lpopt + diff --git a/packaging/usleep.manifest b/packaging/usleep.manifest new file mode 100644 index 0000000..75b0fa5 --- /dev/null +++ b/packaging/usleep.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/usleep.spec b/packaging/usleep.spec new file mode 100644 index 0000000..aac81cc --- /dev/null +++ b/packaging/usleep.spec @@ -0,0 +1,62 @@ +# +# Do not Edit! Generated by: +# spectacle version 0.13 +# +# >> macros +# << macros + +Name: usleep +Summary: Sleeps for microseconds +Version: 1 +Release: 4.2 +Group: System/Base +License: GPLv2 +URL: http://moblin.org/ +Source0: %{name}-%{version}.tar.gz +Source100: usleep.yaml +Source1001: %{name}.manifest +BuildRequires: popt-devel + +%description +A version of /bin/sleep that sleeps for microsecond intervals. + + + +%prep +%setup -q -n %{name}-%{version} + +# >> setup +# << setup + +%build +# >> build pre +# << build pre + +cp %{SOURCE1001} . +make %{?jobs:-j%jobs} + +# >> build post +# << build post +%install +rm -rf %{buildroot} +# >> install pre +# << install pre +%make_install + +# >> install post + + +# << install post + + + + + + +%files +%defattr(-,root,root,-) +%manifest %{name}.manifest +# >> files +%{_mandir}/man*/* +/bin/usleep +# << files diff --git a/packaging/usleep.yaml b/packaging/usleep.yaml new file mode 100644 index 0000000..3d62638 --- /dev/null +++ b/packaging/usleep.yaml @@ -0,0 +1,14 @@ +Name: usleep +Summary: Sleeps for microseconds +Version: 1 +Release: 1 +Group: System/Base +License: GPLv2 +URL: http://moblin.org/ +Sources: + - "%{name}-%{version}.tar.gz" +Description: A version of /bin/sleep that sleeps for microsecond intervals. + +PkgBR: + - popt-devel +Configure: none diff --git a/usleep.1 b/usleep.1 new file mode 100644 index 0000000..2d7520f --- /dev/null +++ b/usleep.1 @@ -0,0 +1,25 @@ +.TH USLEEP 1 "Red Hat, Inc" \" -*- nroff -*- +.SH NAME +usleep \- sleep some number of microseconds +.SH SYNOPSIS +.B usleep +[\fInumber\fP] +.SH DESCRIPTION +.B usleep +sleeps some number of microseconds. The default is 1. +.SH OPTIONS +\fI--usage\fP +Show short usage message. +.TP +\fI--help, -?\fP +Print help information. +.TP +\fI-v, --version\fP +Print version information. +.SH BUGS +Probably not accurate on many machines down to the microsecond. Count +on precision only to -4 or maybe -5. +.SH AUTHOR +Donald Barnes +.br +Erik Troan diff --git a/usleep.c b/usleep.c new file mode 100644 index 0000000..0409498 --- /dev/null +++ b/usleep.c @@ -0,0 +1,82 @@ +/* + * usleep + * + * Written by Donald Barnes for Red Hat, Inc. + * + * Copyright (c) 1997-2003 Red Hat, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + */ + + +#include +#include +#include +#include + +#include "popt.h" + +int main(int argc, char **argv) { + unsigned long count; + poptContext optCon; + int showVersion = 0; + int showOot = 0; + int rc; + char * countStr = NULL; + struct poptOption options[] = { + { "version", 'v', POPT_ARG_NONE, &showVersion, 0, + "Display the version of this program, and exit" }, + { "oot", 'o', POPT_ARG_NONE, &showOot, 0, + "oot says hey!" }, + POPT_AUTOHELP + { 0, 0, 0, 0, 0 } + }; + + optCon = poptGetContext("usleep", argc, argv, options,0); + /*poptReadDefaultConfig(optCon, 1);*/ + poptSetOtherOptionHelp(optCon, "[microseconds]"); + + if ((rc = poptGetNextOpt(optCon)) < -1) { + fprintf(stderr, "usleep: bad argument %s: %s\n", + poptBadOption(optCon, POPT_BADOPTION_NOALIAS), + poptStrerror(rc)); + return 2; + } + + if (showVersion) { + printf("usleep version 1.2\n usleep --help for more info\n"); + return 0; + } + + if (showOot) { + printf("oot says hey!\n"); + return 0; + } + + countStr = poptGetArg(optCon); + + if (countStr == NULL) count = 1; + + else if (countStr && poptGetArg(optCon)) { + fprintf(stderr, "%s: exactly one argument (number of microseconds) " + "must be used\n", argv[0]); + return 2; + } + + else count = strtoul(countStr, NULL, 0); + + usleep(count); + return 0; +}