Skip to content

Commit a2865e8

Browse files
committed
Remove the vestigial support for custom API calling conventions
The computer industry has spoken rather clearly: we shall have 8-bit bytes, powers-of-2- and multiples-of-8-bit ints and floats, one-size-fits-all pointers, and C API calling conventions for system-level interoperability between applications and libraries. So we're going to have all that and we're going to like it. Which we do. We use the opportunity to shed annotations and make libpng less baroque, both in interface and in implementation.
1 parent b950504 commit a2865e8

27 files changed

+366
-487
lines changed

contrib/libtests/makepng.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
745745
}
746746

747747

748-
static void PNGCBAPI
748+
static void
749749
makepng_warning(png_structp png_ptr, png_const_charp message)
750750
{
751751
const char **ep = png_get_error_ptr(png_ptr);
@@ -760,7 +760,7 @@ makepng_warning(png_structp png_ptr, png_const_charp message)
760760
fprintf(stderr, "%s: warning: %s\n", name, message);
761761
}
762762

763-
static void PNGCBAPI
763+
static void
764764
makepng_error(png_structp png_ptr, png_const_charp message)
765765
{
766766
makepng_warning(png_ptr, message);

contrib/libtests/pngimage.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -768,13 +768,13 @@ display_log(struct display *dp, error_level level, const char *fmt, ...)
768768
}
769769

770770
/* error handler callbacks for libpng */
771-
static void PNGCBAPI
771+
static void
772772
display_warning(png_structp pp, png_const_charp warning)
773773
{
774774
display_log(get_dp(pp), LIBPNG_WARNING, "%s", warning);
775775
}
776776

777-
static void PNGCBAPI
777+
static void
778778
display_error(png_structp pp, png_const_charp error)
779779
{
780780
struct display *dp = get_dp(pp);
@@ -858,7 +858,7 @@ buffer_read(struct display *dp, struct buffer *bp, png_bytep data,
858858
bp->read_count = read_count;
859859
}
860860

861-
static void PNGCBAPI
861+
static void
862862
read_function(png_structp pp, png_bytep data, size_t size)
863863
{
864864
buffer_read(get_dp(pp), get_buffer(pp), data, size);
@@ -1325,7 +1325,7 @@ buffer_write(struct display *dp, struct buffer *buffer, png_bytep data,
13251325
buffer->end_count = end_count;
13261326
}
13271327

1328-
static void PNGCBAPI
1328+
static void
13291329
write_function(png_structp pp, png_bytep data, size_t size)
13301330
{
13311331
buffer_write(get_dp(pp), get_buffer(pp), data, size);

contrib/libtests/pngunknown.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,8 @@ clean_display(display *d)
457457
}
458458
}
459459

460-
PNG_FUNCTION(void, display_exit, (display *d), static PNG_NORETURN)
460+
static PNG_NORETURN void
461+
display_exit(display *d)
461462
{
462463
++(d->error_count);
463464

@@ -480,16 +481,16 @@ display_rc(const display *d, int strict)
480481
}
481482

482483
/* libpng error and warning callbacks */
483-
PNG_FUNCTION(void, (PNGCBAPI error), (png_structp png_ptr, const char *message),
484-
static PNG_NORETURN)
484+
static PNG_NORETURN void
485+
error(png_structp png_ptr, const char *message)
485486
{
486487
display *d = (display*)png_get_error_ptr(png_ptr);
487488

488489
fprintf(stderr, "%s(%s): libpng error: %s\n", d->file, d->test, message);
489490
display_exit(d);
490491
}
491492

492-
static void PNGCBAPI
493+
static void
493494
warning(png_structp png_ptr, const char *message)
494495
{
495496
display *d = (display*)png_get_error_ptr(png_ptr);
@@ -531,7 +532,7 @@ get_valid(display *d, png_infop info_ptr)
531532
}
532533

533534
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
534-
static int PNGCBAPI
535+
static int
535536
read_callback(png_structp pp, png_unknown_chunkp pc)
536537
{
537538
/* This function mimics the behavior of png_set_keep_unknown_chunks by

contrib/libtests/pngvalid.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ internal_error(png_store *ps, png_const_charp message)
10931093
#endif /* PNG_READ_SUPPORTED */
10941094

10951095
/* Functions to use as PNG callbacks. */
1096-
static void PNGCBAPI
1096+
static void
10971097
store_error(png_structp ppIn, png_const_charp message) /* PNG_NORETURN */
10981098
{
10991099
png_const_structp pp = ppIn;
@@ -1109,7 +1109,7 @@ store_error(png_structp ppIn, png_const_charp message) /* PNG_NORETURN */
11091109
}
11101110
}
11111111

1112-
static void PNGCBAPI
1112+
static void
11131113
store_warning(png_structp ppIn, png_const_charp message)
11141114
{
11151115
png_const_structp pp = ppIn;
@@ -1281,7 +1281,7 @@ valid_chunktype(png_uint_32 chunktype)
12811281
return 1; /* It's valid */
12821282
}
12831283

1284-
static void PNGCBAPI
1284+
static void
12851285
store_write(png_structp ppIn, png_bytep pb, size_t st)
12861286
{
12871287
png_const_structp pp = ppIn;
@@ -1375,7 +1375,7 @@ store_write(png_structp ppIn, png_bytep pb, size_t st)
13751375
ps->chunklen = chunklen;
13761376
}
13771377

1378-
static void PNGCBAPI
1378+
static void
13791379
store_flush(png_structp ppIn)
13801380
{
13811381
UNUSED(ppIn) /*DOES NOTHING*/
@@ -1700,7 +1700,7 @@ store_read_chunk(png_store *ps, png_bytep pb, size_t max, size_t min)
17001700
return st; /* space left */
17011701
}
17021702

1703-
static void PNGCBAPI
1703+
static void
17041704
store_read(png_structp ppIn, png_bytep pb, size_t st)
17051705
{
17061706
png_const_structp pp = ppIn;
@@ -1903,7 +1903,7 @@ store_pool_delete(png_store *ps, store_pool *pool)
19031903
}
19041904

19051905
/* The memory callbacks: */
1906-
static png_voidp PNGCBAPI
1906+
static png_voidp
19071907
store_malloc(png_structp ppIn, png_alloc_size_t cb)
19081908
{
19091909
png_const_structp pp = ppIn;
@@ -1952,7 +1952,7 @@ store_malloc(png_structp ppIn, png_alloc_size_t cb)
19521952
return new;
19531953
}
19541954

1955-
static void PNGCBAPI
1955+
static void
19561956
store_free(png_structp ppIn, png_voidp memory)
19571957
{
19581958
png_const_structp pp = ppIn;
@@ -3198,7 +3198,7 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, size_t st)
31983198
}
31993199

32003200
/* The callback: */
3201-
static void PNGCBAPI
3201+
static void
32023202
modifier_read(png_structp ppIn, png_bytep pb, size_t st)
32033203
{
32043204
png_const_structp pp = ppIn;
@@ -5391,7 +5391,7 @@ standard_info_imp(standard_display *dp, png_structp pp, png_infop pi,
53915391
standard_info_part2(dp, pp, pi, nImages);
53925392
}
53935393

5394-
static void PNGCBAPI
5394+
static void
53955395
standard_info(png_structp pp, png_infop pi)
53965396
{
53975397
standard_display *dp = voidcast(standard_display*,
@@ -5403,7 +5403,7 @@ standard_info(png_structp pp, png_infop pi)
54035403
standard_info_imp(dp, pp, pi, 1 /*only one image*/);
54045404
}
54055405

5406-
static void PNGCBAPI
5406+
static void
54075407
progressive_row(png_structp ppIn, png_bytep new_row, png_uint_32 y, int pass)
54085408
{
54095409
png_const_structp pp = ppIn;
@@ -5703,7 +5703,7 @@ standard_image_validate(standard_display *dp, png_const_structp pp, int iImage,
57035703
dp->ps->validated = 1;
57045704
}
57055705

5706-
static void PNGCBAPI
5706+
static void
57075707
standard_end(png_structp ppIn, png_infop pi)
57085708
{
57095709
png_const_structp pp = ppIn;
@@ -6703,7 +6703,7 @@ transform_info_imp(transform_display *dp, png_structp pp, png_infop pi)
67036703
}
67046704
}
67056705

6706-
static void PNGCBAPI
6706+
static void
67076707
transform_info(png_structp pp, png_infop pi)
67086708
{
67096709
transform_info_imp(voidcast(transform_display*, png_get_progressive_ptr(pp)),
@@ -6919,7 +6919,7 @@ transform_image_validate(transform_display *dp, png_const_structp pp,
69196919
dp->this.ps->validated = 1;
69206920
}
69216921

6922-
static void PNGCBAPI
6922+
static void
69236923
transform_end(png_structp ppIn, png_infop pi)
69246924
{
69256925
png_const_structp pp = ppIn;
@@ -9385,7 +9385,7 @@ gamma_info_imp(gamma_display *dp, png_structp pp, png_infop pi)
93859385
standard_info_part2(&dp->this, pp, pi, 1 /*images*/);
93869386
}
93879387

9388-
static void PNGCBAPI
9388+
static void
93899389
gamma_info(png_structp pp, png_infop pi)
93909390
{
93919391
gamma_info_imp(voidcast(gamma_display*, png_get_progressive_ptr(pp)), pp,
@@ -10385,7 +10385,7 @@ gamma_image_validate(gamma_display *dp, png_const_structp pp,
1038510385
dp->this.ps->validated = 1;
1038610386
}
1038710387

10388-
static void PNGCBAPI
10388+
static void
1038910389
gamma_end(png_structp ppIn, png_infop pi)
1039010390
{
1039110391
png_const_structp pp = ppIn;

contrib/tools/pngcp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,7 +1674,7 @@ makename(struct display *dp, const char *dir, const char *infile)
16741674
}
16751675

16761676
/* error handler callbacks for libpng */
1677-
static void PNGCBAPI
1677+
static void
16781678
display_warning(png_structp pp, png_const_charp warning)
16791679
{
16801680
struct display *dp = get_dp(pp);
@@ -1684,7 +1684,7 @@ display_warning(png_structp pp, png_const_charp warning)
16841684
display_log(get_dp(pp), LIBPNG_WARNING, "%s", warning);
16851685
}
16861686

1687-
static void PNGCBAPI
1687+
static void
16881688
display_error(png_structp pp, png_const_charp error)
16891689
{
16901690
struct display *dp = get_dp(pp);
@@ -1716,7 +1716,7 @@ display_start_read(struct display *dp, const char *filename)
17161716
display_log(dp, USER_ERROR, "file open failed (%s)", strerror(errno));
17171717
}
17181718

1719-
static void PNGCBAPI
1719+
static void
17201720
read_function(png_structp pp, png_bytep data, size_t size)
17211721
{
17221722
struct display *dp = get_dp(pp);
@@ -1896,7 +1896,7 @@ display_start_write(struct display *dp, const char *filename)
18961896
}
18971897
}
18981898

1899-
static void PNGCBAPI
1899+
static void
19001900
write_function(png_structp pp, png_bytep data, size_t size)
19011901
{
19021902
struct display *dp = get_dp(pp);

contrib/tools/pngfix.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3149,13 +3149,13 @@ read_chunk(struct file *file)
31493149
/* This returns a file* from a png_struct in an implementation specific way. */
31503150
static struct file *get_control(png_const_structrp png_ptr);
31513151

3152-
static void PNGCBAPI
3152+
static void
31533153
error_handler(png_structp png_ptr, png_const_charp message)
31543154
{
31553155
stop(get_control(png_ptr), LIBPNG_ERROR_CODE, message);
31563156
}
31573157

3158-
static void PNGCBAPI
3158+
static void
31593159
warning_handler(png_structp png_ptr, png_const_charp message)
31603160
{
31613161
struct file *file = get_control(png_ptr);
@@ -3167,7 +3167,7 @@ warning_handler(png_structp png_ptr, png_const_charp message)
31673167
/* Read callback - this is where the work gets done to check the stream before
31683168
* passing it to libpng
31693169
*/
3170-
static void PNGCBAPI
3170+
static void
31713171
read_callback(png_structp png_ptr, png_bytep buffer, size_t count)
31723172
/* Return 'count' bytes to libpng in 'buffer' */
31733173
{

manuals/libpng-install.txt

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -345,30 +345,11 @@ way pngusr.h is used in the build has been changed; however, library
345345
builders will probably want to examine the changes to take advantage of
346346
new capabilities and to simplify their build system.
347347

348-
A. Specific changes to library configuration capabilities
349-
350-
The exact mechanism used to control attributes of API functions has
351-
changed. A single set of operating system independent macro definitions
352-
is used and operating system specific directives are defined in
353-
pnglibconf.h
354-
355-
As part of this the mechanism used to choose procedure call standards on
356-
those systems that allow a choice has been changed. At present this only
357-
affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems
358-
running on Intel processors. As before, PNGAPI is defined where required
359-
to control the exported API functions; however, two new macros, PNGCBAPI
360-
and PNGCAPI, are used instead for callback functions (PNGCBAPI) and
361-
(PNGCAPI) for functions that must match a C library prototype (currently
362-
only png_longjmp_ptr, which must match the C longjmp function.) The new
363-
approach is documented in pngconf.h
364-
365-
Despite these changes, libpng 1.5.0 only supports the native C function
366-
calling standard on those platforms tested so far ("__cdecl" on Microsoft
367-
Windows). This is because the support requirements for alternative
368-
calling conventions seem to no longer exist. Developers who find it
369-
necessary to set PNG_API_RULE to 1 should advise the mailing list
370-
(png-mng-implement) of this and library builders who use Openwatcom and
371-
therefore set PNG_API_RULE to 2 should also contact the mailing list.
348+
A. Changes to the library configuration capabilities
349+
350+
A new mechanism to control attributes of API functions was introduced in
351+
libpng-1.5.0. A single set of system-independent macro definitions and
352+
directives is defined in pnglibconf.h
372353

373354
B. Changes to the configuration mechanism
374355

manuals/libpng-manual.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5317,13 +5317,13 @@ We don't use C++ style ("//") comments. We have, however,
53175317
used them in the past in some now-abandoned MMX assembler
53185318
code.
53195319

5320-
Functions and their curly braces are not indented, and
5321-
exported functions are marked with PNGAPI:
5320+
Functions and their curly braces are not indented. We used to mark
5321+
the exported functions with PNGAPI, but we no longer do:
53225322

53235323
/* This is a public function that is visible to
53245324
* application programmers. It does thus-and-so.
53255325
*/
5326-
void PNGAPI
5326+
void
53275327
png_exported_function(png_ptr, png_info, foo)
53285328
{
53295329
body;

manuals/libpng.3

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5826,13 +5826,13 @@ We don't use C++ style ("//") comments. We have, however,
58265826
used them in the past in some now-abandoned MMX assembler
58275827
code.
58285828

5829-
Functions and their curly braces are not indented, and
5830-
exported functions are marked with PNGAPI:
5829+
Functions and their curly braces are not indented. We used to mark
5830+
the exported functions with PNGAPI, but we no longer do:
58315831

58325832
/* This is a public function that is visible to
58335833
* application programmers. It does thus-and-so.
58345834
*/
5835-
void PNGAPI
5835+
void
58365836
png_exported_function(png_ptr, png_info, foo)
58375837
{
58385838
body;

0 commit comments

Comments
 (0)