[Assorted-commits] SF.net SVN: assorted:[1702] shell-tools/trunk
Brought to you by:
yangzhang
From: <yan...@us...> - 2010-09-17 08:37:23
|
Revision: 1702 http://assorted.svn.sourceforge.net/assorted/?rev=1702&view=rev Author: yangzhang Date: 2010-09-17 08:37:17 +0000 (Fri, 17 Sep 2010) Log Message: ----------- Added gccrun Modified Paths: -------------- shell-tools/trunk/README Added Paths: ----------- shell-tools/trunk/src/gccrun.sh Modified: shell-tools/trunk/README =================================================================== --- shell-tools/trunk/README 2010-09-15 18:43:48 UTC (rev 1701) +++ shell-tools/trunk/README 2010-09-17 08:37:17 UTC (rev 1702) @@ -112,12 +112,17 @@ `peakmem` Run a process and get its peak memory usage. bash `local-rsync` Local rsync accelerator without checksum sh - overhead. By Joey Hess. + overhead. By Joey Hess. [Home][lrsync] + +`gccrun` Quickly run C snippets from command line. sh + By Geoff Thomas. [Home][gccrun] -------------------------------------------------------------------------------- [HSH]: http://software.complete.org/hsh/ [Python Commons]: http://assorted.sf.net/python-commons/ [Pexpect]: http://pexpect.sf.net/ +[lrsync]: http://kitenet.net/~joey/blog/entry/local_rsync_accelerator/ +[gccrun]: http://geofft.mit.edu/blog/sipb/132 Usage ----- Added: shell-tools/trunk/src/gccrun.sh =================================================================== --- shell-tools/trunk/src/gccrun.sh (rev 0) +++ shell-tools/trunk/src/gccrun.sh 2010-09-17 08:37:17 UTC (rev 1702) @@ -0,0 +1,45 @@ +#!/bin/sh + +if [ "$#" = 0 ]; then + echo "usage: $0 [-w wrapper] <C code...>" >&2 + exit 1 +fi + +if [ "$1" = -w ]; then + wrapper="$2" + shift 2 +fi + +f=$(mktemp -d -t gccrun.XXXXXXXX) || exit 1 +cat > "$f/command.c" << EOF +#define _GNU_SOURCE +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/mman.h> +#include <sys/ptrace.h> +#include <sys/syscall.h> +#include <fcntl.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +int +main(int argc, char *argv[], char *envp[]) +{ + $@; + return 0; +} +EOF +if ! gcc -o "$f/command" "$f/command.c"; then + exit 1 +fi +if [ -n "$wrapper" ]; then + "$wrapper" "$f/command" +else + "$f/command" +fi +r=$? +rm -r "$f" +exit $r Property changes on: shell-tools/trunk/src/gccrun.sh ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |