LARGEFILE 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. Regarding largefile setup, client apps can be built three ways:
  2. 1. _FILE_OFFSET_BITS == 64 (header maps to mpg123_open_64)
  3. 2. _FILE_OFFSET_BITS == 32 (header maps to mpg123_open_32)
  4. 3. _FILE_OFFSET_BITS == <nothing> (header maps to mpg123_open)
  5. The libmpg123 build needs to be prepared for everything. Also, it needs to keep
  6. in mind the days before introducing large file support --- binaries should still
  7. work with updated libmpg123. So, mpg123_open should always match what is the
  8. default build on a platform without added settings. Those are the platform
  9. variants:
  10. 1. 64 bit native system, long == off_t
  11. libmpg123: mpg123_open
  12. lfs_alias: mpg123_open_64 -> mpg123_open
  13. lfs_wrap: <none>
  14. 2. largefile-sensitive, long = 32, off_t = 64 (if enabled)
  15. libmpg123: mpg123_open_64
  16. lfs_alias: mpg123_open_32 -> mpg123_open
  17. lfs_wrap: mpg123_open -> mpg123_open_64
  18. 3. largefile, long = 32, off_t = 64 (FreeBSD)
  19. libmpg123: mpg123_open
  20. lfs_alias: mpg123_open_64 -> mpg123_open
  21. lfs_wrap: <none>
  22. This is what mpg123 does in version 1.15.4 and it works. Well, for cases 1
  23. (Linux/Solaris x86-64) and 2 (Linux/Solaris x86). Case 3 needs to be added
  24. properly. Actually, let's have a second look at case 2: When mpg123 is built
  25. with --disable-largefile:
  26. 2a. largefile-sensitive, mpg123 built with off_t = 32 == long
  27. libmpg123: mpg123_open
  28. lfs_alias: mpg123_open_32 -> mpg123_open
  29. lfs_wrap: <none>
  30. So, this is still correct. Now, what about case 3? What does mpg123 do
  31. currently, as of 1.15.4?
  32. 3a. largefile, long = 32, off_t = 64 (... and mpg123 not really aware of that)
  33. libmpg123: mpg123_open
  34. lfs_alias: mpg123_open_32(long) -> mpg123_open(off_t)
  35. lfs_wrap: <none>
  36. This is _wrong_. Luckily, this does not cause binary compatibility issues, as
  37. mpg123_open_32 won't be called by anyone unless that someone tries to define
  38. _FILE_OFFSET_BITS=32, which is nonsense. Perhaps old FreeBSD binaries before
  39. LFS times? Well, back then, there was no libmpg123. So let's ignore that case.
  40. The issue at hand is that the alias should be from mpg123_open_64 to
  41. mpg123_open, for clients that insist on defining _FILE_OFFSET_BITS=64.
  42. The change needed now is to fix the naming and also change the type the
  43. alias functions use: It is not long int anymore!
  44. Let's revisit case 1 for a moment: My old lfs_alias.c provides for the case
  45. lfs_alias: mpg123_open -> mpg123_open_64. Is that actually possible?
  46. What means enforcing _FILE_OFFSET_BITS=64 from the outside, which _could_
  47. happen when libmpg123 is included someplace and folks are on the wrong side
  48. of paranoid regarding this. So, there is
  49. 1a. 64 bit native system, long == off_t = 64 and _FILE_OFFSET_BITS=64
  50. libmpg123: mpg123_open_64
  51. lfs_alias: mpg123_open -> mpg123_open_64
  52. lfs_wrap: <none>
  53. (Works also for any system with long == off_t in any width)
  54. Likewise, there is largefile-sensitive system with enforced 32 bits:
  55. 2b. largefile-sensitive, mpg123 with enforced _FILE_OFFSET_BITS=32
  56. libmpg123: mpg123_open_32
  57. lfs_alias: mpg123_open -> mpg123_open_32
  58. lfs_wrap: <none>
  59. All cases are supported with this significant change from 1.15.4:
  60. Make the aliases use a defined lfs_alias_t, which can be long or off_t,
  61. depending on what is the default type for offsets on the platform.
  62. Folks who try _FILE_OFFSET_BITS=32 on a system that only supports
  63. 64 bit get a linking error during mpg123 build (from the _64 aliases),
  64. which I consider to be a feature.
  65. I salute anyone who is not confused after reading this.