Re: Beos Patch

Поиск
Список
Период
Сортировка
Искать

Re: Beos Patch

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Can't apply to 7.1.X, only upcoming 7.2. Applied.


> 
> 
>     Hi bruce,
> 
> 
>     a small patch to keep postgres working on the latest BeOS.
> 
>     If it's possible, can you apply this patch against Current CVS  AND
> REL7_1_STABLE.
> 
>         Thanks
> 
>             cyril

[ Attachment, skipping... ]

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
Index: src/backend/port/beos/support.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/port/beos/support.c,v
retrieving revision 1.4
diff -c -r1.4 support.c
*** src/backend/port/beos/support.c	2001/03/22 03:59:42	1.4
--- src/backend/port/beos/support.c	2001/08/05 21:12:27
***************
*** 115,120 ****
--- 115,136 ----
  	}
  }
  
+ void
+ beos_dl_sym(image_id im,char* symname,void** fptr)
+ {
+ 	/* Send command '3' (get symbol) to the support server */
+ 	write_port(beos_dl_port_in, 3, symname, strlen(symname) + 1);
+ 	write_port(beos_dl_port_in, im, NULL,0);
+ 
+ 	/* Read sym address */
+ 	read_port(beos_dl_port_out, (int32*)(fptr), NULL, 0);
+ 
+ 	if (fptr==NULL)
+ 	{
+ 		elog(NOTICE, "loading symbol '%s' failed ", symname);
+ 	}
+ }
+ 
  status_t
  beos_dl_close(image_id im)
  {
***************
*** 164,175 ****
  			 * server
  			 */
  			read_port(port_in, &opcode, datas, 4000);
! 
  			switch (opcode)
  			{
  					image_id	addon;
  					image_info	info_im;
  					area_info	info_ar;
  
  					/* Load Add-On */
  				case 1:
--- 180,192 ----
  			 * server
  			 */
  			read_port(port_in, &opcode, datas, 4000);
! 			
  			switch (opcode)
  			{
  					image_id	addon;
  					image_info	info_im;
  					area_info	info_ar;
+ 					void  *     fpt;
  
  					/* Load Add-On */
  				case 1:
***************
*** 208,213 ****
--- 225,257 ----
  					write_port(port_out, unload_add_on(*((int *) (datas))), NULL, 0);
  					break;
  					/* Cleanup and exit */
+ 				case 3:
+ 					
+ 					/* read image Id on the input port */
+ 					read_port(port_in, &addon,NULL,0);
+ 
+ 					/* Loading symbol */
+ 					fpt=NULL;
+ 					
+ 			
+ 				if (get_image_symbol(addon, datas, B_SYMBOL_TYPE_TEXT, &fpt) == B_OK);
+ 					{
+ 
+ 						/*
+ 						 * Sometime the loader return B_OK for an inexistant function
+ 						 * with an invalid address !!! Check that the return address
+ 						 * is in the image range
+ 			 			*/
+ 
+ 						get_image_info(addon, &info_im);
+ 						if ((fpt < info_im.text) ||(fpt >= (info_im.text +info_im.text_size)))
+ 							fpt=NULL;
+ 					}
+ 
+ 					/* Send back fptr of data segment */
+ 					write_port(port_out, (int32)(fpt),NULL,0);
+ 					break;
+ 								
  				default:
  					/* Free system resources */
  					delete_port(port_in);
Index: src/backend/port/dynloader/beos.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/port/dynloader/beos.c,v
retrieving revision 1.7
diff -c -r1.7 beos.c
*** src/backend/port/dynloader/beos.c	2001/03/22 03:59:42	1.7
--- src/backend/port/dynloader/beos.c	2001/08/05 21:12:28
***************
*** 49,71 ****
  	/* Checking that "Handle" is valid */
  	if ((handle) && ((*(int *) (handle)) >= 0))
  	{
! 		/* Loading symbol */
! 		if (get_image_symbol(*((int *) (handle)), funcname, B_SYMBOL_TYPE_TEXT, (void **) &fpt) == B_OK);
! 		{
! 
! 			/*
! 			 * Sometime the loader return B_OK for an inexistant function
! 			 * with an invalid address !!! Check that the return address
! 			 * is in the image range
! 			 */
! 			image_info	info;
! 
! 			get_image_info(*((int *) (handle)), &info);
! 			if ((fpt < info.text) ||(fpt >= (info.text +info.text_size)))
! 				return NULL;
! 			return fpt;
! 		}
! 		elog(NOTICE, "loading symbol '%s' failed ", funcname);
  	}
  	elog(NOTICE, "add-on not loaded correctly");
  	return NULL;
--- 49,56 ----
  	/* Checking that "Handle" is valid */
  	if ((handle) && ((*(int *) (handle)) >= 0))
  	{
! 		beos_dl_sym(*((int *) (handle)),funcname,(void **) &fpt);
! 		return fpt;
  	}
  	elog(NOTICE, "add-on not loaded correctly");
  	return NULL;
Index: src/include/port/beos.h
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/port/beos.h,v
retrieving revision 1.9
diff -c -r1.9 beos.h
*** src/include/port/beos.h	2001/03/22 04:00:58	1.9
--- src/include/port/beos.h	2001/08/05 21:12:34
***************
*** 1,5 ****
  #include 
! #include "kernel/image.h"
  
  #define HAS_TEST_AND_SET
  
--- 1,6 ----
  #include 
! #include 
! #include 
  
  #define HAS_TEST_AND_SET
  
***************
*** 68,73 ****
--- 69,77 ----
  
  /* Load a shared library */
  image_id	beos_dl_open(char *filename);
+ 
+ /* Find symbol */
+ void 		beos_dl_sym(image_id im,char* symname,void** fptr);
  
  /* UnLoad a shared library */
  status_t	beos_dl_close(image_id im);

Re: Re: Beos Patch

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Bruce Momjian  writes:
> Can't apply to 7.1.X, only upcoming 7.2. Applied.

Since the patch affects only BeOS-specific code, it seems okay to me
to apply it to 7.1.X too.  There are bigger changes than this in the
REL7_1 branch...

			regards, tom lane

Re: Re: Beos Patch

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
> Bruce Momjian  writes:
> > Can't apply to 7.1.X, only upcoming 7.2. Applied.
> 
> Since the patch affects only BeOS-specific code, it seems okay to me
> to apply it to 7.1.X too.  There are bigger changes than this in the
> REL7_1 branch...

Not having wrote it myself, I am not sure I trust it, but if it looks OK
to you, I will apply it.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
FAQ