| 1 |
Fromscip-debian debian buffer 1.19-12.1 buffer/patches/`0016-Port-to-GCC-15-Closes-1096398.patch`#From.: =?utf-8?b?0L3QsNCx?= <[email protected]scip-debian . . . identity/`[email protected]`.> |
| 2 |
Datescip-debian debian buffer 1.19-12.1 buffer/patches/`0016-Port-to-GCC-15-Closes-1096398.patch`#Date.: Sat, 1 Mar 2025 19:13:27 +0100 |
| 3 |
Subjectscip-debian debian buffer 1.19-12.1 buffer/patches/`0016-Port-to-GCC-15-Closes-1096398.patch`#Subject.: Port to GCC-15 (Closes: #1096398) |
| 4 |
|
| 5 |
--- |
| 6 |
buffer.c | 58 +++++++++++++++++++++++++--------------------------------- |
| 7 |
sem.c | 34 +++++++++++----------------------- |
| 8 |
sem.h | 10 +++++----- |
| 9 |
3 files changed, 41 insertions(+), 61 deletions(-) |
| 10 |
|
| 11 |
diff --git a/buffer.cscip-debian debian buffer 1.19-12.1 buffer/upstream/`buffer.c`: b/buffer.cscip-debian debian buffer 1.19-12.1 buffer/upstream/`buffer.c`: |
| 12 |
index e6b5571..c48a6a3 100644 |
| 13 |
--- a/buffer.c |
| 14 |
+++ b/buffer.c |
| 15 |
@@ -87,27 +87,27 @@ |
| 16 |
* |
| 17 |
* Revision 1.5 90/07/22 18:46:38 lmjm |
| 18 |
* Added system 5 support. |
| 19 |
|
| 20 |
+ * |
| 21 |
* Revision 1.4 90/07/22 18:29:48 lmjm |
| 22 |
* Updated arg handling to be more consistent. |
| 23 |
* Make sofar printing size an option. |
| 24 |
|
| 25 |
+ * |
| 26 |
* Revision 1.3 90/05/15 23:27:46 lmjm |
| 27 |
* Added -S option (show how much has been written). |
| 28 |
* Added -m option to specify how much shared memory to grab. |
| 29 |
* Now tries to fill this with blocks. |
| 30 |
* reader waits for writer to terminate and then frees the shared mem and sems. |
| 31 |
|
| 32 |
+ * |
| 33 |
* Revision 1.2 90/01/20 21:37:59 lmjm |
| 34 |
* Reset default number of blocks and blocksize for best thruput of |
| 35 |
* standard tar 10K Allow. |
| 36 |
* blocks number of blocks to be changed. |
| 37 |
* Don't need a hole in the circular queue since the semaphores prevent block |
| 38 |
* clash. |
| 39 |
|
| 40 |
+ * |
| 41 |
* Revision 1.1 90/01/17 11:30:23 lmjm |
| 42 |
* Initial revision |
| 43 |
|
| 44 |
+ * |
| 45 |
*/ |
| 46 |
#include <stdlib.h> |
| 47 |
#include <string.h> |
| 48 |
@@ -149,13 +149,13 @@ extern char *shmat(); |
| 49 |
#endif |
| 50 |
|
| 51 |
/* Some forward declarations */ |
| 52 |
|
| 53 |
+void byee(int); |
| 54 |
void start_reader_and_writer(); |
| 55 |
|
| 56 |
+void parse_args( int argc, char **argv ); |
| 57 |
void set_handlers(); |
| 58 |
void buffer_allocate(); |
| 59 |
void report_proc(); |
| 60 |
|
| 61 |
+int do_size( char *arg ); |
| 62 |
void get_buffer(); |
| 63 |
void reader(); |
| 64 |
void writer(); |
| 65 |
@@ -166,7 +166,7 @@ void test_writer(); |
| 66 |
int fill_block(); |
| 67 |
void get_next_filled_block(); |
| 68 |
int data_to_write(); |
| 69 |
|
| 70 |
+void write_blocks_to_stdout( int filled, int first_block ); |
| 71 |
void write_block_to_stdout(); |
| 72 |
void pr_out(); |
| 73 |
void end_writer(); |
| 74 |
@@ -200,7 +200,7 @@ int blocksize = DEF_BLOCKSIZE; |
| 75 |
/* Which process... in error reports*/ |
| 76 |
char *proc_string = "buffer"; |
| 77 |
|
| 78 |
|
| 79 |
+/* Numbers of blocks in the queue. |
| 80 |
*/ |
| 81 |
#define MAX_BLOCKS 2048 |
| 82 |
int blocks = 1; |
| 83 |
@@ -267,16 +267,14 @@ NUM_K_TYPE outk = 0; |
| 84 |
struct timeval starttime; |
| 85 |
|
| 86 |
int |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
+main( int argc, char **argv ) |
| 91 |
{ |
| 92 |
parse_args( argc, argv ); |
| 93 |
|
| 94 |
set_handlers(); |
| 95 |
|
| 96 |
buffer_allocate(); |
| 97 |
|
| 98 |
+ |
| 99 |
gettimeofday(&starttime, NULL); |
| 100 |
|
| 101 |
start_reader_and_writer(); |
| 102 |
@@ -288,9 +286,7 @@ main( argc, argv ) |
| 103 |
} |
| 104 |
|
| 105 |
void |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
+parse_args( int argc, char **argv ) |
| 110 |
{ |
| 111 |
int c; |
| 112 |
int iflag = 0; |
| 113 |
@@ -415,7 +411,7 @@ parse_args( argc, argv ) |
| 114 |
byee( -1 ); |
| 115 |
} |
| 116 |
} |
| 117 |
|
| 118 |
+ |
| 119 |
if (argc > optind) { |
| 120 |
fprintf( stderr, "too many arguments\n" ); |
| 121 |
byee( -1 ); |
| 122 |
@@ -453,7 +449,7 @@ parse_args( argc, argv ) |
| 123 |
|
| 124 |
/* The interrupt handler */ |
| 125 |
void |
| 126 |
|
| 127 |
+shutdown( int _ ) |
| 128 |
{ |
| 129 |
static int shutting; |
| 130 |
if( shutting ){ |
| 131 |
@@ -470,7 +466,7 @@ shutdown() |
| 132 |
|
| 133 |
/* Shutdown because the child has ended */ |
| 134 |
void |
| 135 |
|
| 136 |
+child_shutdown( int _ ) |
| 137 |
{ |
| 138 |
/* Find out which child has died. (They may not be my |
| 139 |
* children if buffer was exec'd on top of something that had |
| 140 |
@@ -556,13 +552,13 @@ buffer_allocate() |
| 141 |
* level. However, there doesn't seem to be a good reason to keep one block free, |
| 142 |
* so we initialize the semaphore to "blocks" instead. |
| 143 |
* <[email protected]> 2004-01-11 |
| 144 |
|
| 145 |
+ */ |
| 146 |
#if 0 |
| 147 |
sem_set( pbuffer->semid, pbuffer->blocks_free_lock, blocks - 1 ); |
| 148 |
#else |
| 149 |
sem_set( pbuffer->semid, pbuffer->blocks_free_lock, blocks ); |
| 150 |
#endif |
| 151 |
|
| 152 |
+ |
| 153 |
/* Do not detach the shared memory, but leave it mapped. It will be inherited |
| 154 |
* over fork just fine and this ensures that it's mapped at the same address |
| 155 |
* both in the reader and writer. The original code did a shmdt() here followed |
| 156 |
@@ -600,7 +596,7 @@ buffer_remove() |
| 157 |
if( debug ) |
| 158 |
fprintf( stderr, "%s: removing semaphores and buffer\n", proc_string ); |
| 159 |
remove_sems( pbuffer->semid ); |
| 160 |
|
| 161 |
+ |
| 162 |
if( shmctl( buffer_id, IPC_RMID, (struct shmid_ds *)0 ) == -1 ){ |
| 163 |
report_proc(); |
| 164 |
perror( "failed to remove shared memory buffer" ); |
| 165 |
@@ -693,7 +689,7 @@ fill_block() |
| 166 |
char *start; |
| 167 |
int toread; |
| 168 |
static char eof_reached = 0; |
| 169 |
|
| 170 |
+ |
| 171 |
if( eof_reached ){ |
| 172 |
curr_block->bytes = 0; |
| 173 |
unlock( pbuffer->semid, pbuffer->blocks_used_lock ); |
| 174 |
@@ -806,9 +802,7 @@ data_to_write() |
| 175 |
} |
| 176 |
|
| 177 |
void |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
+write_blocks_to_stdout( int filled, int first_block ) |
| 182 |
{ |
| 183 |
pbuffer->next_block_out = first_block; |
| 184 |
|
| 185 |
@@ -877,8 +871,7 @@ write_block_to_stdout() |
| 186 |
|
| 187 |
|
| 188 |
void |
| 189 |
|
| 190 |
|
| 191 |
+byee( int exit_val ) |
| 192 |
{ |
| 193 |
if( writer_pid != 0 ){ |
| 194 |
if( exit_val != 0 ){ |
| 195 |
@@ -950,8 +943,7 @@ test_writer() |
| 196 |
* b/B for 512 |
| 197 |
*/ |
| 198 |
int |
| 199 |
|
| 200 |
|
| 201 |
+do_size( char *arg ) |
| 202 |
{ |
| 203 |
int ret = 0; |
| 204 |
|
| 205 |
@@ -972,7 +964,7 @@ do_size( arg ) |
| 206 |
ret *= 512; |
| 207 |
break; |
| 208 |
} |
| 209 |
|
| 210 |
+ |
| 211 |
return ret; |
| 212 |
} |
| 213 |
|
| 214 |
@@ -981,7 +973,7 @@ pr_out() |
| 215 |
{ |
| 216 |
struct timeval now; |
| 217 |
unsigned long ms_delta, k_per_s; |
| 218 |
|
| 219 |
+ |
| 220 |
gettimeofday(&now, NULL); |
| 221 |
ms_delta = (now.tv_sec - starttime.tv_sec) * 1000 |
| 222 |
+ (now.tv_usec - starttime.tv_usec) / 1000; |
| 223 |
diff --git a/sem.cscip-debian debian buffer 1.19-12.1 buffer/upstream/`sem.c`: b/sem.cscip-debian debian buffer 1.19-12.1 buffer/upstream/`sem.c`: |
| 224 |
index 69e6a7d..b495f46 100644 |
| 225 |
--- a/sem.c |
| 226 |
+++ b/sem.c |
| 227 |
@@ -56,7 +56,7 @@ union semun { |
| 228 |
ushort *array; |
| 229 |
}; |
| 230 |
#endif |
| 231 |
|
| 232 |
+#endif |
| 233 |
|
| 234 |
/* IMPORTS */ |
| 235 |
|
| 236 |
@@ -64,17 +64,14 @@ union semun { |
| 237 |
extern void report_proc(); |
| 238 |
|
| 239 |
/* Used to end the program - on error */ |
| 240 |
|
| 241 |
+extern void byee(int); |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
/* Set a semaphore to a particular value - meant to be used before |
| 246 |
* first lock/unlock */ |
| 247 |
void |
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
+sem_set( int sem_id, int semn, int val ) |
| 253 |
{ |
| 254 |
union semun arg; |
| 255 |
extern int errno; |
| 256 |
@@ -89,21 +86,20 @@ sem_set( sem_id, semn, val ) |
| 257 |
byee( -1 ); |
| 258 |
} |
| 259 |
} |
| 260 |
|
| 261 |
+ |
| 262 |
int |
| 263 |
|
| 264 |
|
| 265 |
+new_sems( int nsems ) |
| 266 |
{ |
| 267 |
int sem; |
| 268 |
int i; |
| 269 |
|
| 270 |
|
| 271 |
+ sem = semget( IPC_PRIVATE, nsems, IPC_CREAT|0600 ); |
| 272 |
if( sem < 0 ){ |
| 273 |
report_proc(); |
| 274 |
perror( "internal error, couldn't create semaphore" ); |
| 275 |
byee( -1 ); |
| 276 |
} |
| 277 |
|
| 278 |
+ |
| 279 |
for( i = 0; i < nsems; i++ ){ |
| 280 |
sem_set( sem, i, 1 ); |
| 281 |
} |
| 282 |
@@ -112,10 +108,7 @@ new_sems( nsems ) |
| 283 |
} |
| 284 |
|
| 285 |
static void |
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
+do_sem( int sem_id, struct sembuf *pbuf, char *err ) |
| 291 |
{ |
| 292 |
/* This just keeps us going in case of EINTR */ |
| 293 |
while( 1 ){ |
| 294 |
@@ -134,9 +127,7 @@ do_sem( sem_id, pbuf, err ) |
| 295 |
} |
| 296 |
|
| 297 |
void |
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
+lock( int sem_id, int semn ) |
| 302 |
{ |
| 303 |
struct sembuf sembuf; |
| 304 |
|
| 305 |
@@ -148,9 +139,7 @@ lock( sem_id, semn ) |
| 306 |
} |
| 307 |
|
| 308 |
void |
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
+unlock( int sem_id, int semn ) |
| 313 |
{ |
| 314 |
struct sembuf sembuf; |
| 315 |
|
| 316 |
@@ -162,8 +151,7 @@ unlock( sem_id, semn ) |
| 317 |
} |
| 318 |
|
| 319 |
void |
| 320 |
|
| 321 |
|
| 322 |
+remove_sems( int sem_id ) |
| 323 |
{ |
| 324 |
union semun arg; |
| 325 |
|
| 326 |
diff --git a/sem.hscip-debian debian buffer 1.19-12.1 buffer/upstream/`sem.h`: b/sem.hscip-debian debian buffer 1.19-12.1 buffer/upstream/`sem.h`: |
| 327 |
index 9004f95..c61fb95 100644 |
| 328 |
--- a/sem.h |
| 329 |
+++ b/sem.h |
| 330 |
@@ -27,10 +27,10 @@ |
| 331 |
* semaphores */ |
| 332 |
|
| 333 |
/* Allocate new semaphores */ |
| 334 |
|
| 335 |
+int new_sems(int nsems); |
| 336 |
|
| 337 |
/* Perform actions on semaphores */ |
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
+void sem_set(int sem_id, int semn, int val); |
| 343 |
+void lock(int sem_id, int semn); |
| 344 |
+void unlock(int sem_id, int semn); |
| 345 |
+void remove_sems(int sem_id); |