diff options
| author | Yue Du <daviddu@us.ibm.com> | 2015-10-08 13:40:33 -0500 |
|---|---|---|
| committer | Joshua Hunsberger <jahunsbe@us.ibm.com> | 2017-10-23 15:56:18 -0500 |
| commit | a1268463544386716f41f17da0e7e35ee9375343 (patch) | |
| tree | 6ed1fd767335b79422c9605c1b5bc90e4af8330e /import/chips/p9/common/pmlib/ppc405lib/stdlib.c | |
| parent | 286b12fc048eae37ea3ac04ac4aba8778d02d2a4 (diff) | |
| download | talos-hcode-a1268463544386716f41f17da0e7e35ee9375343.tar.gz talos-hcode-a1268463544386716f41f17da0e7e35ee9375343.zip | |
first draft of ppe_closed/cme & sgpe, and common/pmlib/
Change-Id: I08440fadfeff7e4777a776167d4fdcffe5fec82f
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/21058
Tested-by: Jenkins Server
Reviewed-by: Gregory S. Still <stillgs@us.ibm.com>
Diffstat (limited to 'import/chips/p9/common/pmlib/ppc405lib/stdlib.c')
| -rw-r--r-- | import/chips/p9/common/pmlib/ppc405lib/stdlib.c | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/import/chips/p9/common/pmlib/ppc405lib/stdlib.c b/import/chips/p9/common/pmlib/ppc405lib/stdlib.c new file mode 100644 index 00000000..3242cda4 --- /dev/null +++ b/import/chips/p9/common/pmlib/ppc405lib/stdlib.c @@ -0,0 +1,115 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: import/chips/p9/common/pmlib/ppc405lib/stdlib.c $ */ +/* */ +/* OpenPOWER HCODE Project */ +/* */ +/* COPYRIGHT 2015,2017 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +// $Id: stdlib.c,v 1.1.1.1 2013/12/11 20:49:20 bcbrock Exp $ +// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/chips/p8/working/procedures/lib/stdlib.c,v $ +//----------------------------------------------------------------------------- +// *! (C) Copyright International Business Machines Corp. 2013 +// *! All Rights Reserved -- Property of IBM +// *! *** IBM Confidential *** +//----------------------------------------------------------------------------- + +/// \file stdlib.c +/// \brief Functions from <stdlib.h> +/// +/// \note The strtoX() APIs are defined in strtox.[ch] + +#include "ssx.h" +#include "ctype.h" +#include "libssx.h" +#include <stdlib.h> + + +/// Convert a string to a long integer - base 10 only +/// +/// atol(str) is defined here as strtol(str, 0, 10) in sympathy with the POSIX +/// standard. Note that by specification "atol() does not detect +/// errors", however here it will behave the same as the strtol() call just +/// mentioned. + +long +atol(const char* str) +{ + return strtol(str, 0, 10); +} + + +/// Convert a string to an integer - base 10 only +/// +/// atoi(str) is defined here as strtol(str, 0, 10) in sympathy with the POSIX +/// standard. Note that by specification "atoi() does not detect errors", +/// however in this implementation the long integer returned by the strtol() +/// call just mentioned is simply converted to an int. + +int +atoi(const char* str) +{ + return strtol(str, 0, 10); +} + + +/// 'Exit' an application +/// +/// An SSX application can not really 'exit'. By convention, exit(0) is the +/// same as ssx_halt(). Calling exit() with a non-zero code causes a kernel +/// panic - the exit code will be found in R3 on PowerPC. +/// +/// Note that to exit a thread, the thread can either return from the thread +/// entry routine or explicitly call ssx_complete(). exit() was implemented +/// to allow porting of the EEMBC benchmarks. + +void +exit(int status) +{ + if (status) + { + SSX_PANIC(ERROR_EXIT); + } + + ssx_halt(); +} + + +/// Compute the absolute value of the integer argument +int +abs(int i) +{ + return ((i < 0) ? -i : i); +} + + +/// Compute the absolute value of the long integer argument +long int +labs(long int i) +{ + return ((i < 0) ? -i : i); +} + + +/// Compute the absolute value of the long long integer argument +long long int +llabs(long long int i) +{ + return ((i < 0) ? -i : i); +} |

