Skip to content

Commit

Permalink
new package: dgsh
Browse files Browse the repository at this point in the history
  • Loading branch information
xtkoba committed Jan 6, 2022
1 parent a2e9165 commit 5579b4f
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/dgsh/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
TERMUX_PKG_HOMEPAGE=https://www.spinellis.gr/sw/dgsh/
TERMUX_PKG_DESCRIPTION="The directed graph shell"
TERMUX_PKG_LICENSE="Apache-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=1.0.0
TERMUX_PKG_SRCURL=https://github.com/dspinellis/dgsh/archive/refs/tags/v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=22a7f2794e1287a46b03ce38c27a1d9349d1c66535c30e065c8783626555c76c
TERMUX_PKG_BUILD_DEPENDS="check"
TERMUX_PKG_BUILD_IN_SRC=true

termux_step_pre_configure() {
TERMUX_PKG_SRCDIR=$TERMUX_PKG_SRCDIR/core-tools
TERMUX_PKG_BUILDDIR=$TERMUX_PKG_SRCDIR
cd $TERMUX_PKG_BUILDDIR

sed -i -e 's/#.*$//g' src/dgsh-elf.s
cp $TERMUX_PKG_BUILDER_DIR/s_cpow.c src/

touch ../.config
mkdir -p m4
autoreconf -fi
}
11 changes: 11 additions & 0 deletions packages/dgsh/core-tools-src-dgsh-tee.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/core-tools/src/dgsh-tee.c
+++ b/core-tools/src/dgsh-tee.c
@@ -439,7 +439,7 @@
#ifdef FALLOC_FL_PUNCH_HOLE
static bool warned = false;

- if (fallocate(tmp_fd, FALLOC_FL_PUNCH_HOLE, pool * buffer_size, buffer_size) < 0 &&
+ if (fallocate(bp->page_file_fd, FALLOC_FL_PUNCH_HOLE, pool * buffer_size, buffer_size) < 0 &&
!warned) {
warn("Failed to free temporary buffer space");
warned = true;
11 changes: 11 additions & 0 deletions packages/dgsh/core-tools-src-dgsh-w.c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/core-tools/src/dgsh-w.c
+++ b/core-tools/src/dgsh-w.c
@@ -10,6 +10,8 @@
#include "dgsh.h"
#include "dgsh-debug.h"

+#include "s_cpow.c"
+
void
read_number(int fd, long double *x, long double complex *xc)
{
82 changes: 82 additions & 0 deletions packages/dgsh/s_cpow.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*-
* Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/* cpow
*
* Complex power function
*
*
*
* SYNOPSIS:
*
* double complex cpow();
* double complex a, z, w;
*
* w = cpow (a, z);
*
*
*
* DESCRIPTION:
*
* Raises complex A to the complex Zth power.
* Definition is per AMS55 # 4.2.8,
* analytically equivalent to cpow(a,z) = cexp(z clog(a)).
*
* ACCURACY:
*
* Relative error:
* arithmetic domain # trials peak rms
* IEEE -10,+10 30000 9.4e-15 1.5e-15
*
*/

#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");

#include <complex.h>
#include <float.h>
#include <math.h>

#if defined __ANDROID__ && __ANDROID_API__ < 26

#pragma GCC visibility push(hidden)

double complex
cpow(double complex a, double complex z)
{
double complex w;
double x, y, r, theta, absa, arga;

x = creal (z);
y = cimag (z);
absa = cabs (a);
if (absa == 0.0) {
return (CMPLX(0.0, 0.0));
}
arga = carg (a);
r = pow (absa, x);
theta = x * arga;
if (y != 0.0) {
r = r * exp (-y * arga);
theta = theta + y * log (absa);
}
w = CMPLX(r * cos (theta), r * sin (theta));
return (w);
}

#pragma GCC visibility pop

#endif

0 comments on commit 5579b4f

Please sign in to comment.