gcc-6.2 compil fixes

This commit is contained in:
GetAway
2017-01-21 13:55:25 +01:00
committed by Jacek Jendrzej
parent f4e334fa09
commit b5138018b5
7 changed files with 60 additions and 4 deletions

View File

@@ -9,6 +9,9 @@
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#if __cplusplus >= 201103
#include <cmath>
#endif
#include <setjmp.h> #include <setjmp.h>
#include "pictureviewer.h" #include "pictureviewer.h"
@@ -193,12 +196,21 @@ int fh_crw_load(const char *filename,unsigned char **buffer,int* xp,int* /*yp*/)
ciptr->out_color_space=JCS_RGB; ciptr->out_color_space=JCS_RGB;
if(x==(int)ciptr->image_width) if(x==(int)ciptr->image_width)
ciptr->scale_denom=1; ciptr->scale_denom=1;
#if __cplusplus < 201103
else if(abs(x*2 - ciptr->image_width) < 2) else if(abs(x*2 - ciptr->image_width) < 2)
ciptr->scale_denom=2; ciptr->scale_denom=2;
else if(abs(x*4 - ciptr->image_width) < 4) else if(abs(x*4 - ciptr->image_width) < 4)
ciptr->scale_denom=4; ciptr->scale_denom=4;
else if(abs(x*8 - ciptr->image_width) < 8) else if(abs(x*8 - ciptr->image_width) < 8)
ciptr->scale_denom=8; ciptr->scale_denom=8;
#else
else if(std::abs(x*2 - ciptr->image_width) < 2)
ciptr->scale_denom=2;
else if(std::abs(x*4 - ciptr->image_width) < 4)
ciptr->scale_denom=4;
else if(std::abs(x*8 - ciptr->image_width) < 8)
ciptr->scale_denom=8;
#endif
else else
ciptr->scale_denom=1; ciptr->scale_denom=1;

View File

@@ -4,7 +4,7 @@
#include <config.h> #include <config.h>
#include "pv_config.h" #include "pv_config.h"
#ifdef FBV_SUPPORT_JPEG #ifdef FBV_SUPPORT_JPEG
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
@@ -17,7 +17,10 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#if __cplusplus >= 201103
#include <cmath>
#endif
#include <setjmp.h> #include <setjmp.h>
#include <global.h> #include <global.h>
@@ -94,12 +97,21 @@ int fh_jpeg_load(const char *filename,unsigned char **buffer,int* x,int* y)
ciptr->dct_method=JDCT_FASTEST; ciptr->dct_method=JDCT_FASTEST;
if(*x==(int)ciptr->image_width) if(*x==(int)ciptr->image_width)
ciptr->scale_denom=1; ciptr->scale_denom=1;
#if __cplusplus < 201103
else if(abs(*x*2 - ciptr->image_width) < 2) else if(abs(*x*2 - ciptr->image_width) < 2)
ciptr->scale_denom=2; ciptr->scale_denom=2;
else if(abs(*x*4 - ciptr->image_width) < 4) else if(abs(*x*4 - ciptr->image_width) < 4)
ciptr->scale_denom=4; ciptr->scale_denom=4;
else if(abs(*x*8 - ciptr->image_width) < 8) else if(abs(*x*8 - ciptr->image_width) < 8)
ciptr->scale_denom=8; ciptr->scale_denom=8;
#else
else if(std::abs(*x*2 - ciptr->image_width) < 2)
ciptr->scale_denom=2;
else if(std::abs(*x*4 - ciptr->image_width) < 4)
ciptr->scale_denom=4;
else if(std::abs(*x*8 - ciptr->image_width) < 8)
ciptr->scale_denom=8;
#endif
else else
ciptr->scale_denom=1; ciptr->scale_denom=1;

View File

@@ -60,11 +60,17 @@ static inline void list_del(struct list_head *entry)
#define list_entry(ptr, type, member) \ #define list_entry(ptr, type, member) \
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
#if __cplusplus < 201103
#define list_for_each_entry(pos, head, member) \ #define list_for_each_entry(pos, head, member) \
for (pos = list_entry((head)->next, typeof(*pos), member); \ for (pos = list_entry((head)->next, typeof(*pos), member); \
&pos->member != (head); \ &pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member)) pos = list_entry(pos->member.next, typeof(*pos), member))
#else
#define list_for_each_entry(pos, head, member) \
for (pos = list_entry((head)->next, __typeof__(*pos), member); \
&pos->member != (head); \
pos = list_entry(pos->member.next, __typeof__(*pos), member))
#endif
/* Available compressors are on this_ list */ /* Available compressors are on this_ list */
static LIST_HEAD(jffs2_compressor_list); static LIST_HEAD(jffs2_compressor_list);

View File

@@ -44,6 +44,9 @@
#include "common.h" #include "common.h"
#include "compr.h" #include "compr.h"
#if __cplusplus >= 201103
#include "algorithm"
#endif
/* Plan: call deflate() with avail_in == *sourcelen, /* Plan: call deflate() with avail_in == *sourcelen,
avail_out = *dstlen - 12 and flush == Z_FINISH. avail_out = *dstlen - 12 and flush == Z_FINISH.
If it doesn't manage to finish, call it again with If it doesn't manage to finish, call it again with
@@ -76,7 +79,11 @@ static int jffs2_zlib_compress(unsigned char *data_in, unsigned char *cpage_out,
while (strm.total_out < *dstlen - STREAM_END_SPACE && strm.total_in < *sourcelen) { while (strm.total_out < *dstlen - STREAM_END_SPACE && strm.total_in < *sourcelen) {
strm.avail_out = *dstlen - (strm.total_out + STREAM_END_SPACE); strm.avail_out = *dstlen - (strm.total_out + STREAM_END_SPACE);
#if __cplusplus < 201103
strm.avail_in = min((unsigned)(*sourcelen-strm.total_in), strm.avail_out); strm.avail_in = min((unsigned)(*sourcelen-strm.total_in), strm.avail_out);
#else
strm.avail_in = std::min((unsigned)(*sourcelen-strm.total_in), strm.avail_out);
#endif
ret = deflate(&strm, Z_PARTIAL_FLUSH); ret = deflate(&strm, Z_PARTIAL_FLUSH);
if (ret != Z_OK) { if (ret != Z_OK) {
deflateEnd(&strm); deflateEnd(&strm);

View File

@@ -37,13 +37,15 @@
extern "C" { extern "C" {
#endif #endif
#ifndef MIN /* some C lib headers define this for us */ #if __cplusplus < 201103
#ifndef MIN /* some C lib headers define this for us */
#define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif #endif
#ifndef MAX #ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif #endif
#define min(a, b) MIN(a, b) /* glue for linux kernel source */ #define min(a, b) MIN(a, b) /* glue for linux kernel source */
#endif
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#ifndef O_CLOEXEC #ifndef O_CLOEXEC

View File

@@ -66,6 +66,9 @@
#include <crc32.h> #include <crc32.h>
#include <inttypes.h> #include <inttypes.h>
#if __cplusplus >= 201103
#include <algorithm>
#endif
#include <string> #include <string>
#include "rbtree.h" #include "rbtree.h"
@@ -755,7 +758,11 @@ void CMkfsJFFS2::pad_block_if_less_than(int req)
void CMkfsJFFS2::padblock(void) void CMkfsJFFS2::padblock(void)
{ {
while (out_ofs % erase_block_size) { while (out_ofs % erase_block_size) {
#if __cplusplus < 201103
full_write(out_fd, ffbuf, min(sizeof(ffbuf), full_write(out_fd, ffbuf, min(sizeof(ffbuf),
#else
full_write(out_fd, ffbuf, std::min(sizeof(ffbuf),
#endif
(size_t)(erase_block_size - (out_ofs % erase_block_size)))); (size_t)(erase_block_size - (out_ofs % erase_block_size))));
} }
} }
@@ -868,7 +875,11 @@ void CMkfsJFFS2::create_target_filesystem(struct filesystem_entry *root)
} }
} else { } else {
while (out_ofs < pad_fs_size) { while (out_ofs < pad_fs_size) {
#if __cplusplus < 201103
full_write(out_fd, ffbuf, min(sizeof(ffbuf), (size_t)(pad_fs_size - out_ofs))); full_write(out_fd, ffbuf, min(sizeof(ffbuf), (size_t)(pad_fs_size - out_ofs)));
#else
full_write(out_fd, ffbuf, std::min(sizeof(ffbuf), (size_t)(pad_fs_size - out_ofs)));
#endif
} }
} }

View File

@@ -136,9 +136,15 @@ static inline void rb_set_color(struct rb_node *rb, int color)
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif #endif
#if __cplusplus < 201103
#define container_of(ptr, type, member) ({ \ #define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );}) (type *)( (char *)__mptr - offsetof(type,member) );})
#else
#define container_of(ptr, type, member) ({ \
const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
#endif
#define rb_entry(ptr, type, member) container_of(ptr, type, member) #define rb_entry(ptr, type, member) container_of(ptr, type, member)