home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / pc_hw / nearptr / nearptr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-23  |  1.2 KB  |  34 lines

  1. /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
  2. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  3. #include <sys/nearptr.h>
  4. #include <sys/exceptn.h>
  5. #include <crt0.h>
  6. #include <dpmi.h>
  7. #include <go32.h>
  8.  
  9. /* Functions to enable "near" pointer access to DOS memory under DPMI
  10.    CW Sandmann 7-95  NO WARRANTY: WARNING, since these functions disable
  11.    memory protection, they MAY DESTROY EVERYTHING ON YOUR COMPUTER! */
  12.  
  13. int __djgpp_nearptr_enable(void)
  14. {
  15.   if(!__dpmi_set_segment_limit(_my_ds(), 0xffffffffU)) {
  16.     if(__dpmi_get_segment_limit(_my_ds()) != 0xffffffffU)
  17.       return 0;        /* We set it but DPMI ignored/truncated it */
  18.     __dpmi_set_segment_limit(__djgpp_ds_alias, 0xffffffffU);
  19.     __dpmi_set_segment_limit(_my_cs(), 0xffffffffU);
  20.     _crt0_startup_flags |= _CRT0_FLAG_NEARPTR;
  21.     return 1;
  22.   }
  23.   return 0;
  24. }
  25.  
  26.  
  27. void __djgpp_nearptr_disable(void)
  28. {
  29.   __dpmi_set_segment_limit(_my_cs(), __djgpp_selector_limit | 0xfff);
  30.   __dpmi_set_segment_limit(__djgpp_ds_alias, __djgpp_selector_limit | 0xfff);
  31.   __dpmi_set_segment_limit(_my_ds(), __djgpp_selector_limit | 0xfff);
  32.   _crt0_startup_flags &= ~_CRT0_FLAG_NEARPTR;
  33. }
  34.