aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-04-23 20:42:36 +0200
committerMattias Andrée <maandree@operamail.com>2014-04-23 20:42:36 +0200
commitad5dd4f1ffaa8c859543ebed63836fda830abbe5 (patch)
tree50e4595aaa0c44cccb3c772f372fedb47277b9b5
parentadd deps list (diff)
downloadautopasswd-ad5dd4f1ffaa8c859543ebed63836fda830abbe5.tar.gz
autopasswd-ad5dd4f1ffaa8c859543ebed63836fda830abbe5.tar.bz2
autopasswd-ad5dd4f1ffaa8c859543ebed63836fda830abbe5.tar.xz
add makefile
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--DEPENDENCIES2
-rw-r--r--Makefile39
-rw-r--r--src/sha3.c24
-rw-r--r--src/sha3.h46
4 files changed, 75 insertions, 36 deletions
diff --git a/DEPENDENCIES b/DEPENDENCIES
index 086b182..2b00df9 100644
--- a/DEPENDENCIES
+++ b/DEPENDENCIES
@@ -9,6 +9,6 @@ BUILD DEPENDENCIES:
libpassphrase https://github.com/GNU-Pony/libpassphrase
argparser-c https://github.com/maandree/argparser
make
- cc
+ c99
coreutils
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..f2283a9
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,39 @@
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved. This file is offered as-is,
+# without any warranty.
+
+OPTIMISE = -Ofast
+
+WARN = -Wall -Wextra -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs \
+ -Wtrampolines -Wfloat-equal -Wshadow -Wmissing-prototypes -Wmissing-declarations \
+ -Wredundant-decls -Wnested-externs -Winline -Wno-variadic-macros -Wsign-conversion \
+ -Wswitch-default -Wconversion -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align \
+ -Wstrict-overflow -Wundef -Wbad-function-cast -Wcast-qual -Wwrite-strings -Wpacked \
+ -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition \
+ -Wvector-operation-performance -Wunsuffixed-float-constants -Wsuggest-attribute=const \
+ -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsuggest-attribute=format \
+ -Wnormalized=nfkc -pedantic -Wdeclaration-after-statement
+
+F_OPTS = -ftree-vrp -fstrict-aliasing -fipa-pure-const -fstack-usage -fstrict-overflow \
+ -funsafe-loop-optimizations -fno-builtin
+
+X =
+
+STD = c99
+
+FLAGS = $(OPTIMISE) -std=$(STD) $(WARN) $(F_OPTS) $(X) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -DWITH_C99
+
+
+all: bin/autopasswd
+
+bin/autopasswd: obj/autopasswd.o obj/sha3.o
+ @mkdir -p bin
+ $(CC) $(FLAGS) -fwhole-program -lpassphrase -largparser -o $@ $^
+
+obj/%.o: src/%.c src/sha3.h
+ @mkdir -p obj
+ $(CC) $(FLAGS) -c -o $@ $<
+
+clean:
+ -rm -r bin obj
diff --git a/src/sha3.c b/src/sha3.c
index c460b5f..ce35f38 100644
--- a/src/sha3.c
+++ b/src/sha3.c
@@ -20,17 +20,17 @@
#ifdef WITH_C99
- #define static_inline static inline
+# define static_inline static inline
#else
- #define static_inline inline
+# define static_inline inline
#endif
#ifdef WITH_THREADLOCAL
- #define threadlocal __thread
+# define threadlocal __thread
/* This is compiler dependent, if your compiler does
* not support this you need to define __thread yourself. */
#else
- #define threadlocal /* no threading support */
+# define threadlocal /* no threading support */
#endif
#define null 0
@@ -520,7 +520,7 @@ static_inline byte* sha3_pad10star1(byte* restrict_ msg, long len, long r, long*
* @param capacity The capacity
* @param output The output size
*/
-extern void sha3_initialise(long bitrate, long capacity, long output)
+void sha3_initialise(long bitrate, long capacity, long output)
{
long i;
@@ -550,7 +550,7 @@ extern void sha3_initialise(long bitrate, long capacity, long output)
/**
* Dispose of the Keccak sponge
*/
-extern void sha3_dispose()
+void sha3_dispose()
{
#ifdef WITH_WIPE
long i;
@@ -581,7 +581,7 @@ extern void sha3_dispose()
* @param msg The partial message
* @param msglen The length of the partial message
*/
-extern void sha3_update(byte* restrict_ msg, long msglen)
+void sha3_update(byte* restrict_ msg, long msglen)
{
long rr = r >> 3;
long ww = w >> 3;
@@ -659,7 +659,7 @@ extern void sha3_update(byte* restrict_ msg, long msglen)
* @param withReturn Whether to return the hash instead of just do a quick squeeze phrase and return {@code null}
* @return The hash sum, or {@code null} if <tt>withReturn</tt> is {@code false}
*/
-extern byte* sha3_digest(byte* restrict_ msg, long msglen, boolean withReturn)
+byte* sha3_digest(byte* restrict_ msg, long msglen, boolean withReturn)
{
byte* message;
byte* _msg;
@@ -777,7 +777,7 @@ extern byte* sha3_digest(byte* restrict_ msg, long msglen, boolean withReturn)
*
* @param times The number of rounds
*/
-extern void sha3_simpleSqueeze(long times)
+void sha3_simpleSqueeze(long times)
{
long i;
for (i = 0; i < times; i++)
@@ -790,7 +790,7 @@ extern void sha3_simpleSqueeze(long times)
*
* @param times The number of digests
*/
-extern void sha3_fastSqueeze(long times)
+void sha3_fastSqueeze(long times)
{
long i, olen;
for (i = 0; i < times; i++)
@@ -808,7 +808,7 @@ extern void sha3_fastSqueeze(long times)
*
* @return The hash sum
*/
-extern byte* sha3_squeeze(void)
+byte* sha3_squeeze(void)
{
long nn, ww, olen, i, j, ptr, ni;
byte* rc;
@@ -852,7 +852,7 @@ extern byte* sha3_squeeze(void)
*
* @return A 25-element array with the state, changes will be applied to the sponge
*/
-extern llong* sha3_state(void)
+llong* sha3_state(void)
{
return S;
}
diff --git a/src/sha3.h b/src/sha3.h
index f984df5..a6cf321 100644
--- a/src/sha3.h
+++ b/src/sha3.h
@@ -23,22 +23,22 @@
#ifdef WITH_C99
- #include <inttypes.h>
- #define restrict_ restrict
- #define byte int_fast8_t
- #define boolean int_fast8_t
- #define llong int_fast64_t
- #define ullong uint_fast64_t
+# include <inttypes.h>
+# define restrict_ restrict
+# define byte int_fast8_t
+# define boolean int_fast8_t
+# define llong int_fast64_t
+# define ullong uint_fast64_t
#else
- #define restrict_ /* introduced in C99 */
- #define byte char
- #define boolean char
- #if __x86_64__ || __ppc64__
- #define llong long int
- #else
- #define llong long long int
- #endif
- #define ullong unsigned llong
+# define restrict_ /* introduced in C99 */
+# define byte char
+# define boolean char
+# if __x86_64__ || __ppc64__
+# define llong long int
+# else
+# define llong long long int
+# endif
+# define ullong unsigned llong
#endif
@@ -50,13 +50,13 @@
* @param capacity The capacity
* @param output The output size
*/
-extern void sha3_initialise(long bitrate, long capacity, long output);
+void sha3_initialise(long bitrate, long capacity, long output);
/**
* Dispose of the Keccak sponge
*/
-extern void sha3_dispose(void);
+void sha3_dispose(void);
/**
@@ -65,7 +65,7 @@ extern void sha3_dispose(void);
* @param msg The partial message
* @param msglen The length of the partial message
*/
-extern void sha3_update(byte* restrict_ msg, long msglen);
+void sha3_update(byte* restrict_ msg, long msglen);
/**
@@ -76,7 +76,7 @@ extern void sha3_update(byte* restrict_ msg, long msglen);
* @param withReturn Whether to return the hash instead of just do a quick squeeze phrase and return {@code null}
* @return The hash sum, or {@code null} if <tt>withReturn</tt> is {@code false}
*/
-extern byte* sha3_digest(byte* restrict_ msg, long msglen, boolean withReturn);
+byte* sha3_digest(byte* restrict_ msg, long msglen, boolean withReturn);
/**
@@ -84,7 +84,7 @@ extern byte* sha3_digest(byte* restrict_ msg, long msglen, boolean withReturn);
*
* @param times The number of rounds
*/
-extern void sha3_simpleSqueeze(long times);
+void sha3_simpleSqueeze(long times);
/**
@@ -92,7 +92,7 @@ extern void sha3_simpleSqueeze(long times);
*
* @param times The number of digests
*/
-extern void sha3_fastSqueeze(long times);
+void sha3_fastSqueeze(long times);
/**
@@ -100,7 +100,7 @@ extern void sha3_fastSqueeze(long times);
*
* @return The hash sum
*/
-extern byte* sha3_squeeze(void);
+byte* sha3_squeeze(void);
/**
@@ -108,7 +108,7 @@ extern byte* sha3_squeeze(void);
*
* @return A 25-element array with the state, changes will be applied to the sponge
*/
-extern llong* sha3_state(void);
+llong* sha3_state(void);
#endif